Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add python 3.11 support #320

Merged
merged 30 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b1cfda6
feat: add python 3.12 support
edx-requirements-bot Feb 23, 2024
fcc5a4c
refactor: remove extra blank spaces
mariajgrimaldi Mar 28, 2024
d56053a
refactor: use python 3.11 instead of python 3.12
mariajgrimaldi Mar 28, 2024
fce1c6c
refactor: use environment with same django version
mariajgrimaldi Mar 28, 2024
8380a55
fix: remove duplicated deps key from file
mariajgrimaldi Mar 28, 2024
dec9239
fix: manage python versions in ci workflow
mariajgrimaldi Mar 28, 2024
b81903d
fix: add constraint for backports-zoneinfo < python 3.9
mariajgrimaldi Apr 11, 2024
87e5c23
fix: add correct name for django settings module variable
mariajgrimaldi Apr 11, 2024
a3ed3e1
refactor: run bad args for callable test for python3.8/3.11
mariajgrimaldi Apr 11, 2024
1a293a6
fix: use minor attribute instead of version tuple
mariajgrimaldi Apr 11, 2024
51c150b
fix: temporarily remove failing tests for python 3.11
mariajgrimaldi Apr 11, 2024
699e0da
refactor: manage python versions in CI workflow and tox.ini file
mariajgrimaldi Apr 11, 2024
14e015a
refactor: modify tests so they pass in newer versions
mariajgrimaldi Apr 11, 2024
04dcd8f
refactor: use operators valid for all python versions
mariajgrimaldi Apr 11, 2024
89439a0
refactor!: drop support for python3.12
mariajgrimaldi Apr 11, 2024
9eabe68
fix: run coverage for django42 tox env
mariajgrimaldi Apr 11, 2024
b05803b
fix: don't fail for coverage report upload
mariajgrimaldi Apr 11, 2024
1b42ffe
refactor: run bad args for callable test for python3.8/3.11
mariajgrimaldi Apr 11, 2024
45bf145
fix: go back to previous quality definition
mariajgrimaldi Apr 11, 2024
abb16b1
fix: remove extra blank line
mariajgrimaldi Apr 11, 2024
21aadb3
fix: add missing period for docstring
mariajgrimaldi Apr 11, 2024
b1402b5
fix: run isort in test module
mariajgrimaldi Apr 11, 2024
f953534
fix: add again pydocstyle docs
mariajgrimaldi Apr 11, 2024
e8ec5ac
docs: add inline comment explaining why skip test in different versions
mariajgrimaldi Apr 11, 2024
d756b3c
build: drop temp solution for astroid recursion error
mariajgrimaldi Apr 11, 2024
cfff93e
Revert "build: drop temp solution for astroid recursion error"
mariajgrimaldi Apr 11, 2024
e82569f
refactor: address PR reviews
mariajgrimaldi Apr 11, 2024
33b8248
fix: remove tests folder from tests commands
mariajgrimaldi Apr 11, 2024
8a0a6ee
refactor: put check back for the time being
mariajgrimaldi Apr 11, 2024
c419544
fix: remove tests folder from tests commands
mariajgrimaldi Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Python CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches:
- '**'
- '**'


jobs:
Expand All @@ -15,30 +15,30 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: ["quality", "docs", "django32", "django42"]
python-version: ['3.8', '3.11']
toxenv: ["django42", "quality", "docs"]

steps:
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v3
with:
flags: unittests
fail_ci_if_error: true
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v3
with:
flags: unittests
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion openedx_events/content_authoring/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class LibraryBlockData:
@attr.s(frozen=True)
class ContentObjectData:
"""
Data about changed content object
Data about changed content object.

Arguments:
object_id (str): identifier of the Content object. This represents the id of the course or library block
Expand Down
17 changes: 17 additions & 0 deletions openedx_events/event_bus/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"""

import copy
import sys
import warnings
from contextlib import contextmanager
from unittest import TestCase

import pytest
from django.test import override_settings

from openedx_events.data import EventsMetadata
Expand Down Expand Up @@ -83,6 +85,7 @@ def test_missing_attribute(self):
)
assert loaded == {'def': 'ault'}

@pytest.mark.skipif(sys.version_info > (3, 9), reason="Python 3.8.x required")
@override_settings(EB_LOAD_PATH='builtins.dict')
def test_bad_args_for_callable(self):
with assert_warnings([
Expand All @@ -96,6 +99,20 @@ def test_bad_args_for_callable(self):
)
assert loaded == {'def': 'ault'}

@pytest.mark.skipif(sys.version_info < (3, 9), reason="Python 3.11.x required")
@override_settings(EB_LOAD_PATH='builtins.dict')
def test_bad_args_for_callable(self):
with assert_warnings([
"Failed to load <class 'dict'> from setting EB_LOAD_PATH: "
"TypeError('dict() argument after * must be an iterable, not int'); "
"component will be inactive"
]):
loaded = _try_load(
setting_name="EB_LOAD_PATH", args=(1), kwargs={'2': 3},
expected_class=dict, default={'def': 'ault'},
)
assert loaded == {'def': 'ault'}


class TestProducer(TestCase):

Expand Down
14 changes: 6 additions & 8 deletions openedx_events/tests/test_producer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ def test_enabled_disabled_events(self, mock_producer):
XBLOCK_PUBLISHED.send_event(xblock_info=self.xblock_info)
mock_send.send.assert_called()
mock_send.send.call_count = 2
expected_call_args = [
{'topic': 'enabled_topic_a', 'event_key_field': 'xblock_info.usage_key'},
{'topic': 'enabled_topic_b', 'event_key_field': 'xblock_info.usage_key'}
]

# check that call_args_list only consists of enabled topics.
call_args = mock_send.send.call_args_list[0][1]
self.assertDictContainsSubset(
{'topic': 'enabled_topic_a', 'event_key_field': 'xblock_info.usage_key'},
call_args
)
self.assertEqual(call_args, {**call_args, **expected_call_args[0]})
call_args = mock_send.send.call_args_list[1][1]
self.assertDictContainsSubset(
{'topic': 'enabled_topic_b', 'event_key_field': 'xblock_info.usage_key'},
call_args
)
self.assertEqual(call_args, {**call_args, **expected_call_args[1]})

@patch("openedx_events.apps.logger")
@patch('openedx_events.apps.get_producer')
Expand Down
6 changes: 4 additions & 2 deletions openedx_events/tests/test_tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ def test_generate_signal_metadata(self, datetime_mock, socket_mock, events_packa
}

metadata = self.public_signal.generate_signal_metadata()
metadata_as_dict = attr.asdict(metadata)

self.assertDictContainsSubset(expected_metadata, attr.asdict(metadata))
self.assertEqual(metadata_as_dict, {**expected_metadata, **metadata_as_dict})
self.assertIsInstance(metadata.id, UUID)

@override_settings(SERVICE_VARIANT="lms")
Expand All @@ -138,8 +139,9 @@ def test_generate_signal_metadata_with_valid_time(self, socket_mock, events_pack
}

metadata = self.public_signal.generate_signal_metadata(time=expected_time)
metadata_as_dict = attr.asdict(metadata)

self.assertDictContainsSubset(expected_metadata, attr.asdict(metadata))
self.assertEqual(metadata_as_dict, {**expected_metadata, **metadata_as_dict})
self.assertIsInstance(metadata.id, UUID)

@ddt.data(
Expand Down
14 changes: 8 additions & 6 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ asgiref==3.8.1
# via django
attrs==23.2.0
# via -r requirements/base.in
backports-zoneinfo==0.2.1
# via django
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# django
cffi==1.16.0
# via pynacl
click==8.1.7
Expand All @@ -25,19 +27,19 @@ django-crum==0.7.9
# via edx-django-utils
django-waffle==4.1.0
# via edx-django-utils
edx-django-utils==5.11.0
edx-django-utils==5.12.0
# via -r requirements/base.in
edx-opaque-keys[django]==2.5.1
# via -r requirements/base.in
fastavro==1.9.4
# via -r requirements/base.in
newrelic==9.7.1
newrelic==9.8.0
# via edx-django-utils
pbr==6.0.0
# via stevedore
psutil==5.9.8
# via edx-django-utils
pycparser==2.21
pycparser==2.22
# via cffi
pymongo==3.13.0
# via edx-opaque-keys
Expand All @@ -49,7 +51,7 @@ stevedore==5.2.0
# via
# edx-django-utils
# edx-opaque-keys
typing-extensions==4.10.0
typing-extensions==4.11.0
# via
# asgiref
# edx-opaque-keys
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ colorama==0.4.6
# via tox
distlib==0.3.8
# via virtualenv
filelock==3.13.1
filelock==3.13.4
# via
# tox
# virtualenv
Expand Down
4 changes: 4 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
# This should be removed once the issue is fixed with a new astroid release or with a test_generate_avro_schemas.py
# module refactor.
astroid<3.0.0


# Temporary to Support the python 3.11 Upgrade
backports.zoneinfo;python_version<"3.9" # Newer versions have zoneinfo available in the standard library
Comment on lines +19 to +20
Copy link
Member

@mariajgrimaldi mariajgrimaldi Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

27 changes: 16 additions & 11 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ astroid==2.15.8
# pylint-celery
attrs==23.2.0
# via -r requirements/quality.txt
backports-zoneinfo==0.2.1
backports-tarfile==1.0.0
# via
# -r requirements/quality.txt
# jaraco-context
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# -r requirements/quality.txt
# django
build==1.1.1
build==1.2.1
# via
# -r requirements/pip-tools.txt
# pip-tools
Expand Down Expand Up @@ -106,7 +111,7 @@ docutils==0.20.1
# via
# -r requirements/quality.txt
# readme-renderer
edx-django-utils==5.11.0
edx-django-utils==5.12.0
# via -r requirements/quality.txt
edx-lint==5.3.6
# via -r requirements/quality.txt
Expand All @@ -118,7 +123,7 @@ exceptiongroup==1.2.0
# pytest
fastavro==1.9.4
# via -r requirements/quality.txt
filelock==3.13.1
filelock==3.13.4
# via
# -r requirements/ci.txt
# tox
Expand Down Expand Up @@ -147,11 +152,11 @@ isort==5.13.2
# via
# -r requirements/quality.txt
# pylint
jaraco-classes==3.3.1
jaraco-classes==3.4.0
# via
# -r requirements/quality.txt
# keyring
jaraco-context==4.3.0
jaraco-context==5.3.0
# via
# -r requirements/quality.txt
# keyring
Expand All @@ -169,7 +174,7 @@ jinja2==3.1.3
# -r requirements/quality.txt
# code-annotations
# diff-cover
keyring==25.0.0
keyring==25.1.0
# via
# -r requirements/quality.txt
# twine
Expand Down Expand Up @@ -198,11 +203,11 @@ more-itertools==10.2.0
# -r requirements/quality.txt
# jaraco-classes
# jaraco-functools
newrelic==9.7.1
newrelic==9.8.0
# via
# -r requirements/quality.txt
# edx-django-utils
nh3==0.2.15
nh3==0.2.17
# via
# -r requirements/quality.txt
# readme-renderer
Expand Down Expand Up @@ -245,7 +250,7 @@ psutil==5.9.8
# edx-django-utils
pycodestyle==2.11.1
# via -r requirements/quality.txt
pycparser==2.21
pycparser==2.22
# via
# -r requirements/quality.txt
# cffi
Expand Down Expand Up @@ -379,7 +384,7 @@ tox==4.14.2
# via -r requirements/ci.txt
twine==5.0.0
# via -r requirements/quality.txt
typing-extensions==4.10.0
typing-extensions==4.11.0
# via
# -r requirements/quality.txt
# asgiref
Expand Down
Loading
Loading