Skip to content

Commit

Permalink
feat: add python311 support
Browse files Browse the repository at this point in the history
  • Loading branch information
UsamaSadiq committed Mar 26, 2024
1 parent 18383e0 commit 8fce03a
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 60 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ccx_keys/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""init"""

__version__ = '1.2.1'
__version__ = '1.2.2'
3 changes: 1 addition & 2 deletions ccx_keys/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
23 changes: 12 additions & 11 deletions ccx_keys/tests/test_ccx_keys.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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
)
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
)
Expand All @@ -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):
Expand All @@ -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)
Expand Down
18 changes: 4 additions & 14 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
# SERIOUSLY.
#
# ------------------------------
# Generated by edx-lint version: 5.2.5
# Generated by edx-lint version: 5.3.6
# ------------------------------
[MASTER]
ignore =
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -223,8 +218,6 @@ enable =
protected-access,
redundant-unittest-assert,
reimported,
simplifiable-if-statement,
simplifiable-range,
singleton-comparison,
superfluous-parens,
unidiomatic-typecheck,
Expand All @@ -233,7 +226,6 @@ enable =
unnecessary-semicolon,
unneeded-not,
useless-else-on-loop,
wrong-assert-type,

deprecated-method,
deprecated-module,
Expand All @@ -259,6 +251,7 @@ enable =
useless-suppression,
disable =
bad-indentation,
broad-exception-raised,
consider-using-f-string,
duplicate-code,
file-ignored,
Expand All @@ -282,9 +275,6 @@ disable =
unused-wildcard-import,
use-maxsplit-arg,

feature-toggle-needs-doc,
illegal-waffle-usage,

logging-fstring-interpolation,

[REPORTS]
Expand Down Expand Up @@ -380,6 +370,6 @@ ext-import-graph =
int-import-graph =

[EXCEPTIONS]
overgeneral-exceptions = Exception
overgeneral-exceptions = builtins.Exception

# 0bb4a6d612f83352ced91b8f50942dfac7d30cd2
# 1ef2d4041d23cbdf1b1032b907726f55a2fb264a
4 changes: 2 additions & 2 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ filelock==3.13.1
# via
# tox
# virtualenv
packaging==23.2
packaging==24.0
# via
# pyproject-api
# tox
Expand All @@ -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
9 changes: 9 additions & 0 deletions requirements/common_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 10 additions & 9 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 8 additions & 6 deletions requirements/pip-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions requirements/quality.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-c constraints.txt

pycodestyle
pylint
edx-lint
Loading

0 comments on commit 8fce03a

Please sign in to comment.