From 8fce03a1c4fae670076b3b1595df23843cb9e61b Mon Sep 17 00:00:00 2001 From: Usama Sadiq Date: Thu, 21 Mar 2024 23:00:46 +0500 Subject: [PATCH] feat: add python311 support --- .github/workflows/ci.yml | 11 +++-- Makefile | 1 + ccx_keys/__init__.py | 2 +- ccx_keys/locator.py | 3 +- ccx_keys/tests/test_ccx_keys.py | 23 +++++----- pylintrc | 18 ++------ requirements/ci.txt | 4 +- requirements/common_constraints.txt | 9 ++++ requirements/dev.txt | 19 ++++---- requirements/pip-tools.txt | 14 +++--- requirements/pip.txt | 4 +- requirements/quality.in | 5 +++ requirements/quality.txt | 70 +++++++++++++++++++++++++++++ requirements/test.txt | 10 ++--- setup.py | 1 + tox.ini | 6 ++- 16 files changed, 140 insertions(+), 60 deletions(-) create mode 100644 requirements/quality.in create mode 100644 requirements/quality.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0182404..80cf356 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,13 +16,12 @@ jobs: matrix: os: - ubuntu-20.04 - python-version: - - 3.8 - toxenv: [ py38, quality ] + python-version: ['3.8', '3.11'] + toxenv: [ unittest, quality ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -35,7 +34,7 @@ jobs: run: tox - name: Run Coverage - if: matrix.python-version == '3.8' && matrix.toxenv=='py38' + if: matrix.python-version == '3.8' && matrix.toxenv=='unittest' uses: codecov/codecov-action@v2 with: fail_ci_if_error: true diff --git a/Makefile b/Makefile index 0610314..e97c828 100644 --- a/Makefile +++ b/Makefile @@ -31,3 +31,4 @@ upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with pip-compile --rebuild --upgrade -o requirements/test.txt requirements/test.in pip-compile --rebuild --upgrade -o requirements/ci.txt requirements/ci.in pip-compile --rebuild --upgrade -o requirements/dev.txt requirements/dev.in + pip-compile --rebuild --upgrade -o requirements/quality.txt requirements/quality.in diff --git a/ccx_keys/__init__.py b/ccx_keys/__init__.py index 9ba2c6c..338a614 100644 --- a/ccx_keys/__init__.py +++ b/ccx_keys/__init__.py @@ -1,3 +1,3 @@ """init""" -__version__ = '1.2.1' +__version__ = '1.2.2' diff --git a/ccx_keys/locator.py b/ccx_keys/locator.py index 3fd21bb..aa3ef2a 100644 --- a/ccx_keys/locator.py +++ b/ccx_keys/locator.py @@ -74,7 +74,6 @@ def to_course_locator(self): """ Returns a CourseLocator representing this location. """ - # pylint: disable=no-member return CourseLocator( org=self.org, course=self.course, @@ -146,7 +145,7 @@ def _from_string(cls, serialized): deserialization of block """ # Allow access to _from_string protected method - course_key = CCXLocator._from_string(serialized) # pylint: disable=protected-access + course_key = CCXLocator._from_string(serialized) parsed_parts = cls.parse_url(serialized) block_id = parsed_parts.get('block_id', None) if block_id is None: diff --git a/ccx_keys/tests/test_ccx_keys.py b/ccx_keys/tests/test_ccx_keys.py index 0bf4b8d..231e670 100644 --- a/ccx_keys/tests/test_ccx_keys.py +++ b/ccx_keys/tests/test_ccx_keys.py @@ -1,6 +1,7 @@ """ Tests for the ccx_keys package. """ -import ddt -import itertools # pylint: disable=wrong-import-order +import itertools + +import ddt # pylint: disable=import-error from bson.objectid import ObjectId from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey, UsageKey @@ -22,7 +23,7 @@ def test_ccx_constructor_package_id(self): course = '6002x' run = '2014_T2' ccx = '1' - testurn = '{}+{}+{}+{}@{}'.format( # lint-amnesty, pylint: disable=consider-using-f-string + testurn = '{}+{}+{}+{}@{}'.format( org, course, run, CCXLocator.CCX_PREFIX, ccx ) testobj = CCXLocator(org=org, course=course, run=run, ccx=ccx) @@ -39,7 +40,7 @@ def test_ccx_constructor_version_guid(self): """Verify a locator constructed with only version_guid is correct""" test_id_loc = '519665f6223ebd6980884f2b' ccx = '1' - expected_urn = '{}@{}+{}@{}'.format( # lint-amnesty, pylint: disable=consider-using-f-string + expected_urn = '{}@{}+{}@{}'.format( CCXLocator.VERSION_PREFIX, test_id_loc, CCXLocator.CCX_PREFIX, ccx ) @@ -61,7 +62,7 @@ def test_ccx_constructor_package_id_separate_branch(self): run = '2014_T2' test_branch = 'published' ccx = '1' - expected_urn = '{}+{}+{}+{}@{}+{}@{}'.format( # lint-amnesty, pylint: disable=consider-using-f-string + expected_urn = '{}+{}+{}+{}@{}+{}@{}'.format( org, course, run, CCXLocator.BRANCH_PREFIX, test_branch, CCXLocator.CCX_PREFIX, ccx @@ -90,7 +91,7 @@ def test_ccx_constructor_package_id_branch_and_version_guid(self): run = '2014_T2' branch = 'draft-1' ccx = '1' - expected_urn = '{}+{}+{}+{}@{}+{}@{}+{}@{}'.format( # lint-amnesty, pylint: disable=consider-using-f-string + expected_urn = '{}+{}+{}+{}@{}+{}@{}+{}@{}'.format( org, course, run, CCXLocator.BRANCH_PREFIX, branch, CCXLocator.VERSION_PREFIX, test_id_loc, @@ -274,16 +275,16 @@ class TestCCXBlockUsageLocator(LocatorBaseTest): @ddt.data( # do we need or even want to support deprecated forms of urls? - "ccx-block-v1:org+course+run+ccx@1+{}@category+{}@name".format(CCXBlockUsageLocator.BLOCK_TYPE_PREFIX, # lint-amnesty, pylint: disable=consider-using-f-string + "ccx-block-v1:org+course+run+ccx@1+{}@category+{}@name".format(CCXBlockUsageLocator.BLOCK_TYPE_PREFIX, CCXBlockUsageLocator.BLOCK_PREFIX), - "ccx-block-v1:org+course+run+{}@revision+ccx@1+{}@category+{}@name".format( # lint-amnesty, pylint: disable=consider-using-f-string + "ccx-block-v1:org+course+run+{}@revision+ccx@1+{}@category+{}@name".format( CourseLocator.BRANCH_PREFIX, CCXBlockUsageLocator.BLOCK_TYPE_PREFIX, CCXBlockUsageLocator.BLOCK_PREFIX), "i4x://org/course/category/name@revision", # now try the extended char sets - we expect that "%" should be OK in deprecated-style ids, # but should not be valid in new-style ids - "ccx-block-v1:org.dept.sub-prof+course.num.section-4+run.hour.min-99+ccx@1+{}@category+{}@name:12.33-44".format( # lint-amnesty, pylint: disable=consider-using-f-string + "ccx-block-v1:org.dept.sub-prof+course.num.section-4+run.hour.min-99+ccx@1+{}@category+{}@name:12.33-44".format( CCXBlockUsageLocator.BLOCK_TYPE_PREFIX, CCXBlockUsageLocator.BLOCK_PREFIX), "i4x://org.dept%sub-prof/course.num%section-4/category/name:12%33-44", ) @@ -296,7 +297,7 @@ def test_string_roundtrip(self, url): @ddt.data( f"ccx-block-v1:org+course+run+ccx@1+{CCXBlockUsageLocator.BLOCK_TYPE_PREFIX}@category", - "ccx-block-v1:org+course+run+{}@revision+ccx@1+{}@category".format(CourseLocator.BRANCH_PREFIX, # lint-amnesty, pylint: disable=consider-using-f-string + "ccx-block-v1:org+course+run+{}@revision+ccx@1+{}@category".format(CourseLocator.BRANCH_PREFIX, CCXBlockUsageLocator.BLOCK_TYPE_PREFIX), ) def test_missing_block_id(self, url): @@ -308,7 +309,7 @@ def test_missing_block_id(self, url): ('org', 'course', 'run', '1', 'category', 'name:more_name', None), ) @ddt.unpack - def test_valid_locations(self, org, course, run, ccx, category, name, revision): # pylint: disable=unused-argument + def test_valid_locations(self, org, course, run, ccx, category, name, revision): course_key = CCXLocator(org=org, course=course, run=run, branch=revision, ccx=ccx) locator = CCXBlockUsageLocator(course_key, block_type=category, block_id=name, ) self.assertEqual(org, locator.org) diff --git a/pylintrc b/pylintrc index 044bb0c..5c2ed36 100644 --- a/pylintrc +++ b/pylintrc @@ -64,7 +64,7 @@ # SERIOUSLY. # # ------------------------------ -# Generated by edx-lint version: 5.2.5 +# Generated by edx-lint version: 5.3.6 # ------------------------------ [MASTER] ignore = @@ -141,7 +141,6 @@ enable = no-self-argument, no-value-for-parameter, non-iterator-returned, - non-parent-method-called, nonexistent-operator, not-a-mapping, not-an-iterable, @@ -161,13 +160,10 @@ enable = return-outside-function, signature-differs, super-init-not-called, - super-method-not-called, syntax-error, - test-inherits-tests, too-few-format-args, too-many-format-args, too-many-function-args, - translation-of-non-string, truncated-format-string, undefined-all-variable, undefined-loop-variable, @@ -213,7 +209,6 @@ enable = consider-using-enumerate, global-at-module-level, global-variable-not-assigned, - literal-used-as-attribute, logging-format-interpolation, logging-not-lazy, multiple-imports, @@ -223,8 +218,6 @@ enable = protected-access, redundant-unittest-assert, reimported, - simplifiable-if-statement, - simplifiable-range, singleton-comparison, superfluous-parens, unidiomatic-typecheck, @@ -233,7 +226,6 @@ enable = unnecessary-semicolon, unneeded-not, useless-else-on-loop, - wrong-assert-type, deprecated-method, deprecated-module, @@ -259,6 +251,7 @@ enable = useless-suppression, disable = bad-indentation, + broad-exception-raised, consider-using-f-string, duplicate-code, file-ignored, @@ -282,9 +275,6 @@ disable = unused-wildcard-import, use-maxsplit-arg, - feature-toggle-needs-doc, - illegal-waffle-usage, - logging-fstring-interpolation, [REPORTS] @@ -380,6 +370,6 @@ ext-import-graph = int-import-graph = [EXCEPTIONS] -overgeneral-exceptions = Exception +overgeneral-exceptions = builtins.Exception -# 0bb4a6d612f83352ced91b8f50942dfac7d30cd2 +# 1ef2d4041d23cbdf1b1032b907726f55a2fb264a diff --git a/requirements/ci.txt b/requirements/ci.txt index 88a39ff..9f335db 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -16,7 +16,7 @@ filelock==3.13.1 # via # tox # virtualenv -packaging==23.2 +packaging==24.0 # via # pyproject-api # tox @@ -32,7 +32,7 @@ tomli==2.0.1 # via # pyproject-api # tox -tox==4.13.0 +tox==4.14.1 # via -r requirements/ci.in virtualenv==20.25.1 # via tox diff --git a/requirements/common_constraints.txt b/requirements/common_constraints.txt index 96cc5db..e3bf8ea 100644 --- a/requirements/common_constraints.txt +++ b/requirements/common_constraints.txt @@ -21,3 +21,12 @@ elasticsearch<7.14.0 # django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected django-simple-history==3.0.0 + +# opentelemetry requires version 6.x at the moment: +# https://github.com/open-telemetry/opentelemetry-python/issues/3570 +# Normally this could be added as a constraint in edx-django-utils, where we're +# adding the opentelemetry dependency. However, when we compile pip-tools.txt, +# that uses version 7.x, and then there's no undoing that when compiling base.txt. +# So we need to pin it globally, for now. +# Ticket for unpinning: https://github.com/openedx/edx-lint/issues/407 +importlib-metadata<7 diff --git a/requirements/dev.txt b/requirements/dev.txt index 963cc00..da89842 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -35,7 +35,7 @@ click-log==0.4.0 # via # -r requirements/test.txt # edx-lint -code-annotations==1.6.0 +code-annotations==1.7.0 # via # -r requirements/test.txt # edx-lint @@ -44,7 +44,7 @@ colorama==0.4.6 # -r requirements/ci.txt # -r requirements/test.txt # tox -coverage==7.4.3 +coverage==7.4.4 # via -r requirements/test.txt ddt==1.7.2 # via -r requirements/test.txt @@ -71,8 +71,9 @@ filelock==3.13.1 # -r requirements/test.txt # tox # virtualenv -importlib-metadata==7.0.1 +importlib-metadata==6.11.0 # via + # -c requirements/common_constraints.txt # -r requirements/pip-tools.txt # build iniconfig==2.0.0 @@ -99,7 +100,7 @@ mccabe==0.7.0 # pylint mock==5.1.0 # via -r requirements/test.txt -packaging==23.2 +packaging==24.0 # via # -r requirements/ci.txt # -r requirements/pip-tools.txt @@ -112,7 +113,7 @@ pbr==6.0.0 # via # -r requirements/test.txt # stevedore -pip-tools==7.4.0 +pip-tools==7.4.1 # via -r requirements/pip-tools.txt platformdirs==4.2.0 # via @@ -163,7 +164,7 @@ pyproject-hooks==1.0.0 # -r requirements/pip-tools.txt # build # pip-tools -pytest==8.1.0 +pytest==8.1.1 # via -r requirements/test.txt python-slugify==8.0.4 # via @@ -202,7 +203,7 @@ tomlkit==0.12.4 # via # -r requirements/test.txt # pylint -tox==4.13.0 +tox==4.14.1 # via # -r requirements/ci.txt # -r requirements/test.txt @@ -217,11 +218,11 @@ virtualenv==20.25.1 # -r requirements/ci.txt # -r requirements/test.txt # tox -wheel==0.42.0 +wheel==0.43.0 # via # -r requirements/pip-tools.txt # pip-tools -zipp==3.17.0 +zipp==3.18.1 # via # -r requirements/pip-tools.txt # importlib-metadata diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index 8528adb..b1ac4e5 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -8,11 +8,13 @@ build==1.1.1 # via pip-tools click==8.1.7 # via pip-tools -importlib-metadata==7.0.1 - # via build -packaging==23.2 +importlib-metadata==6.11.0 + # via + # -c requirements/common_constraints.txt + # build +packaging==24.0 # via build -pip-tools==7.4.0 +pip-tools==7.4.1 # via -r requirements/pip-tools.in pyproject-hooks==1.0.0 # via @@ -23,9 +25,9 @@ tomli==2.0.1 # build # pip-tools # pyproject-hooks -wheel==0.42.0 +wheel==0.43.0 # via pip-tools -zipp==3.17.0 +zipp==3.18.1 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/pip.txt b/requirements/pip.txt index 6665603..cf44902 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -4,11 +4,11 @@ # # make upgrade # -wheel==0.42.0 +wheel==0.43.0 # via -r requirements/pip.in # The following packages are considered to be unsafe in a requirements file: pip==24.0 # via -r requirements/pip.in -setuptools==69.1.1 +setuptools==69.2.0 # via -r requirements/pip.in diff --git a/requirements/quality.in b/requirements/quality.in new file mode 100644 index 0000000..fbd6d7a --- /dev/null +++ b/requirements/quality.in @@ -0,0 +1,5 @@ +-c constraints.txt + +pycodestyle +pylint +edx-lint diff --git a/requirements/quality.txt b/requirements/quality.txt new file mode 100644 index 0000000..5352656 --- /dev/null +++ b/requirements/quality.txt @@ -0,0 +1,70 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# make upgrade +# +astroid==3.1.0 + # via + # pylint + # pylint-celery +click==8.1.7 + # via + # click-log + # code-annotations + # edx-lint +click-log==0.4.0 + # via edx-lint +code-annotations==1.7.0 + # via edx-lint +dill==0.3.8 + # via pylint +edx-lint==5.3.6 + # via -r requirements/quality.in +isort==5.13.2 + # via pylint +jinja2==3.1.3 + # via code-annotations +markupsafe==2.1.5 + # via jinja2 +mccabe==0.7.0 + # via pylint +pbr==6.0.0 + # via stevedore +platformdirs==4.2.0 + # via pylint +pycodestyle==2.11.1 + # via -r requirements/quality.in +pylint==3.1.0 + # via + # -r requirements/quality.in + # edx-lint + # pylint-celery + # pylint-django + # pylint-plugin-utils +pylint-celery==0.3 + # via edx-lint +pylint-django==2.5.5 + # via edx-lint +pylint-plugin-utils==0.8.2 + # via + # pylint-celery + # pylint-django +python-slugify==8.0.4 + # via code-annotations +pyyaml==6.0.1 + # via code-annotations +six==1.16.0 + # via edx-lint +stevedore==5.2.0 + # via code-annotations +text-unidecode==1.3 + # via python-slugify +tomli==2.0.1 + # via pylint +tomlkit==0.12.4 + # via pylint +typing-extensions==4.10.0 + # via + # astroid + # pylint diff --git a/requirements/test.txt b/requirements/test.txt index ed5bd70..396ff0b 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -19,11 +19,11 @@ click==8.1.7 # edx-lint click-log==0.4.0 # via edx-lint -code-annotations==1.6.0 +code-annotations==1.7.0 # via edx-lint colorama==0.4.6 # via tox -coverage==7.4.3 +coverage==7.4.4 # via -r requirements/test.in ddt==1.7.2 # via -r requirements/test.in @@ -55,7 +55,7 @@ mccabe==0.7.0 # via pylint mock==5.1.0 # via -r requirements/test.in -packaging==23.2 +packaging==24.0 # via # pyproject-api # pytest @@ -95,7 +95,7 @@ pymongo==3.13.0 # edx-opaque-keys pyproject-api==1.6.1 # via tox -pytest==8.1.0 +pytest==8.1.1 # via -r requirements/test.in python-slugify==8.0.4 # via code-annotations @@ -120,7 +120,7 @@ tomli==2.0.1 # tox tomlkit==0.12.4 # via pylint -tox==4.13.0 +tox==4.14.1 # via -r requirements/test.in typing-extensions==4.10.0 # via diff --git a/setup.py b/setup.py index 64967f7..9c97c1c 100644 --- a/setup.py +++ b/setup.py @@ -67,6 +67,7 @@ def get_version(file_path): 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.11', ], packages=[ 'ccx_keys', diff --git a/tox.ini b/tox.ini index 692aefc..d4d8848 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] -envlist = py38,quality +envlist = unittest, quality -[testenv] +[testenv:unittest] deps = -r{toxinidir}/requirements/test.txt commands = @@ -10,6 +10,8 @@ commands = coverage xml [testenv:quality] +deps = + -r{toxinidir}/requirements/quality.txt commands = pycodestyle --config=.pep8 ccx_keys pylint --rcfile=pylintrc ccx_keys