From 07c74fcd2a0643842a0b1ecd3013c0c315a3029c Mon Sep 17 00:00:00 2001 From: edX requirements bot <49161187+edx-requirements-bot@users.noreply.github.com> Date: Fri, 15 Jan 2021 05:50:19 -0500 Subject: [PATCH] Python Code Cleanup (#14) * Python code cleanup by the cleanup-python-code Jenkins job. This pull request was generated by the cleanup-python-code Jenkins job, which ran ``` modernize_travis;modernize_tox;make upgrade;find . -type f -name '*.py' | while read fname; do pyupgrade --exit-zero-even-if-changed --keep-percent-format --py3-plus --py36-plus --py38-plus "$fname"; done ``` The following packages were installed: `pyupgrade,git+https://github.com/edx/repo-tools.git@c05453b733602ba7a2224ffbbf58a8d0903b62d8` * Drop Python 3.5 Co-authored-by: Zulqarnain --- .travis.yml | 10 ++----- ccx_keys/locator.py | 8 ++--- ccx_keys/tests/test_ccx_keys.py | 19 ++++++------ requirements/base.txt | 10 +++---- requirements/dev.txt | 52 +++++++++++++++------------------ requirements/pip-tools.txt | 3 +- requirements/test.txt | 48 ++++++++++++++---------------- requirements/travis.txt | 19 +++++------- setup.py | 5 +--- tox.ini | 20 ++++++------- 10 files changed, 85 insertions(+), 109 deletions(-) diff --git a/.travis.yml b/.travis.yml index 45eb757..e276b6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,13 @@ language: python python: - - 3.5 - - 3.8 + - '3.8' install: - pip install pip==20.0.2 - make requirements - pip install coveralls envs: - TOXENV=quality -matrix: - include: - - python: 3.5 - env: TOXENV=py35 - - python: 3.8 - env: TOXENV=py38 + - TOXENV=py38 script: - tox after_success: diff --git a/ccx_keys/locator.py b/ccx_keys/locator.py index 2dccba9..0d905ff 100644 --- a/ccx_keys/locator.py +++ b/ccx_keys/locator.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Locator module. """ import re @@ -25,7 +24,6 @@ class CCXLocator(CourseLocator, CCXKey): # pep8 and pylint don't agree on the indentation in this block; let's make # pep8 happy and ignore pylint as that's easier to do. - # pylint: disable=bad-continuation URL_RE_SOURCE = r""" ((?P{ALLOWED_ID_CHARS}+)\+(?P{ALLOWED_ID_CHARS}+)(\+(?P{ALLOWED_ID_CHARS}+))?{SEP})?? ({BRANCH_PREFIX}@(?P{ALLOWED_ID_CHARS}+){SEP})? @@ -56,7 +54,7 @@ def __init__(self, **kwargs): if kwargs.get('deprecated', False): raise InvalidKeyError(self.__class__, "cannot be deprecated") - super(CCXLocator, self).__init__(**kwargs) + super().__init__(**kwargs) @classmethod def from_course_locator(cls, course_locator, ccx): @@ -89,7 +87,7 @@ def _to_string(self): """ Return a string representing this location. """ - string = super(CCXLocator, self)._to_string() + string = super()._to_string() # append the identifier for the ccx to the existing course string string += "+{prefix}@{ccx}".format( prefix=self.CCX_PREFIX, ccx=self.ccx @@ -141,7 +139,7 @@ def replace(self, **kwargs): if course_key_kwargs: kwargs['course_key'] = self.course_key.replace(**course_key_kwargs) - return super(CCXBlockUsageLocator, self).replace(**kwargs) + return super().replace(**kwargs) @classmethod def _from_string(cls, serialized): diff --git a/ccx_keys/tests/test_ccx_keys.py b/ccx_keys/tests/test_ccx_keys.py index 98b0952..4e85cae 100644 --- a/ccx_keys/tests/test_ccx_keys.py +++ b/ccx_keys/tests/test_ccx_keys.py @@ -1,5 +1,4 @@ """ Tests for the ccx_keys package. """ -import six import ddt import itertools # pylint: disable=wrong-import-order from bson.objectid import ObjectId @@ -135,9 +134,9 @@ def test_missing_ccx_id(self, fields): 'run': '2014_T2', 'branch': 'draft-1', } - use_fields = dict( - (k, v) for k, v in list(available_fields.items()) if k in fields - ) + use_fields = { + k: v for k, v in list(available_fields.items()) if k in fields + } with self.assertRaises(InvalidKeyError) as context_manager: CCXLocator(**use_fields) @@ -182,9 +181,9 @@ def test_locator_from_good_url(self, fields, url_template): } this_url = url_template.format(**available_fields) testobj = CourseKey.from_string(this_url) - use_keys = dict( - (k, v) for k, v in list(available_fields.items()) if k in fields - ) + use_keys = { + k: v for k, v in list(available_fields.items()) if k in fields + } if 'version_guid' in use_keys: use_keys['version_guid'] = ObjectId(use_keys['version_guid']) @@ -235,7 +234,7 @@ def test_from_course_locator_constructor(self, fields): 'branch': 'draft-1', } ccx = '1' - use_fields = dict((k, v) for k, v in list(available_fields.items()) if k in fields) + use_fields = {k: v for k, v in list(available_fields.items()) if k in fields} course_id = CourseLocator(**use_fields) testobj = CCXLocator.from_course_locator(course_id, ccx) @@ -289,14 +288,14 @@ class TestCCXBlockUsageLocator(LocatorBaseTest): "i4x://org.dept%sub-prof/course.num%section-4/category/name:12%33-44", ) def test_string_roundtrip(self, url): - actual = six.text_type(UsageKey.from_string(url)) + actual = str(UsageKey.from_string(url)) self.assertEqual( url, actual ) @ddt.data( - "ccx-block-v1:org+course+run+ccx@1+{}@category".format(CCXBlockUsageLocator.BLOCK_TYPE_PREFIX), + 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, CCXBlockUsageLocator.BLOCK_TYPE_PREFIX), ) diff --git a/requirements/base.txt b/requirements/base.txt index 5071f90..8be43be 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -4,8 +4,8 @@ # # make upgrade # -edx-opaque-keys==2.1.0 # via -r requirements/base.in -pbr==5.4.5 # via stevedore -pymongo==3.10.1 # via edx-opaque-keys -six==1.14.0 # via -r requirements/base.in, edx-opaque-keys, stevedore -stevedore==1.32.0 # via edx-opaque-keys +edx-opaque-keys==2.1.1 # via -r requirements/base.in +pbr==5.5.1 # via stevedore +pymongo==3.11.2 # via edx-opaque-keys +six==1.15.0 # via -r requirements/base.in, edx-opaque-keys +stevedore==3.3.0 # via edx-opaque-keys diff --git a/requirements/dev.txt b/requirements/dev.txt index a9d9c20..dc7b9be 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -4,44 +4,40 @@ # # make upgrade # -appdirs==1.4.3 # via -r requirements/test.txt, -r requirements/travis.txt, virtualenv -astroid==2.3.3 # via -r requirements/test.txt, pylint, pylint-celery +appdirs==1.4.4 # via -r requirements/test.txt, -r requirements/travis.txt, virtualenv +astroid==2.4.2 # via -r requirements/test.txt, pylint, pylint-celery click-log==0.3.2 # via -r requirements/test.txt, edx-lint click==7.1.2 # via -r requirements/pip-tools.txt, -r requirements/test.txt, click-log, edx-lint, pip-tools -coverage==5.1 # via -r requirements/test.txt -ddt==1.3.1 # via -r requirements/test.txt -distlib==0.3.0 # via -r requirements/test.txt, -r requirements/travis.txt, virtualenv -edx-lint==1.4.1 # via -r requirements/test.txt -edx-opaque-keys==2.1.0 # via -r requirements/test.txt +coverage==5.3.1 # via -r requirements/test.txt +ddt==1.4.1 # via -r requirements/test.txt +distlib==0.3.1 # via -r requirements/test.txt, -r requirements/travis.txt, virtualenv +edx-lint==1.6 # via -r requirements/test.txt +edx-opaque-keys==2.1.1 # via -r requirements/test.txt filelock==3.0.12 # via -r requirements/test.txt, -r requirements/travis.txt, tox, virtualenv -importlib-metadata==1.6.0 # via -r requirements/test.txt, -r requirements/travis.txt, importlib-resources, pluggy, tox, virtualenv -importlib-resources==1.5.0 # via -r requirements/test.txt, -r requirements/travis.txt, virtualenv -isort==4.3.21 # via -r requirements/test.txt, pylint +isort==5.7.0 # via -r requirements/test.txt, pylint lazy-object-proxy==1.4.3 # via -r requirements/test.txt, astroid mccabe==0.6.1 # via -r requirements/test.txt, pylint -mock==3.0.5 # via -r requirements/test.txt +mock==4.0.3 # via -r requirements/test.txt nose==1.3.7 # via -r requirements/test.txt -packaging==20.3 # via -r requirements/test.txt, -r requirements/travis.txt, tox -pbr==5.4.5 # via -r requirements/test.txt, stevedore -pip-tools==5.1.2 # via -r requirements/pip-tools.txt +packaging==20.8 # via -r requirements/test.txt, -r requirements/travis.txt, tox +pbr==5.5.1 # via -r requirements/test.txt, stevedore +pip-tools==5.5.0 # via -r requirements/pip-tools.txt pluggy==0.13.1 # via -r requirements/test.txt, -r requirements/travis.txt, tox -py==1.8.1 # via -r requirements/test.txt, -r requirements/travis.txt, tox -pycodestyle==2.5.0 # via -r requirements/test.txt +py==1.10.0 # via -r requirements/test.txt, -r requirements/travis.txt, tox +pycodestyle==2.6.0 # via -r requirements/test.txt pylint-celery==0.3 # via -r requirements/test.txt, edx-lint -pylint-django==2.0.11 # via -r requirements/test.txt, edx-lint +pylint-django==2.3.0 # via -r requirements/test.txt, edx-lint pylint-plugin-utils==0.6 # via -r requirements/test.txt, pylint-celery, pylint-django -pylint==2.4.2 # via -r requirements/test.txt, edx-lint, pylint-celery, pylint-django, pylint-plugin-utils -pymongo==3.10.1 # via -r requirements/test.txt, edx-opaque-keys +pylint==2.6.0 # via -r requirements/test.txt, edx-lint, pylint-celery, pylint-django, pylint-plugin-utils +pymongo==3.11.2 # via -r requirements/test.txt, edx-opaque-keys pyparsing==2.4.7 # via -r requirements/test.txt, -r requirements/travis.txt, packaging -six==1.14.0 # via -r requirements/pip-tools.txt, -r requirements/test.txt, -r requirements/travis.txt, astroid, edx-lint, edx-opaque-keys, mock, packaging, pip-tools, stevedore, tox, virtualenv -stevedore==1.32.0 # via -r requirements/test.txt, edx-opaque-keys -toml==0.10.0 # via -r requirements/test.txt, -r requirements/travis.txt, tox -tox-battery==0.5.2 # via -r requirements/dev.in -tox==3.15.0 # via -r requirements/test.txt, -r requirements/travis.txt, tox-battery -typed-ast==1.4.1 # via -r requirements/test.txt, astroid -virtualenv==20.0.20 # via -r requirements/test.txt, -r requirements/travis.txt, tox -wrapt==1.11.2 # via -r requirements/test.txt, astroid -zipp==1.2.0 # via -r requirements/test.txt, -r requirements/travis.txt, importlib-metadata, importlib-resources +six==1.15.0 # via -r requirements/test.txt, -r requirements/travis.txt, astroid, edx-lint, edx-opaque-keys, tox, virtualenv +stevedore==3.3.0 # via -r requirements/test.txt, edx-opaque-keys +toml==0.10.2 # via -r requirements/test.txt, -r requirements/travis.txt, pylint, tox +tox-battery==0.6.1 # via -r requirements/dev.in +tox==3.21.0 # via -r requirements/test.txt, -r requirements/travis.txt, tox-battery +virtualenv==20.3.0 # via -r requirements/test.txt, -r requirements/travis.txt, tox +wrapt==1.12.1 # via -r requirements/test.txt, astroid # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index 89fbde9..b7f1765 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -5,8 +5,7 @@ # make upgrade # click==7.1.2 # via pip-tools -pip-tools==5.1.2 # via -r requirements/pip-tools.in -six==1.14.0 # via pip-tools +pip-tools==5.5.0 # via -r requirements/pip-tools.in # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/requirements/test.txt b/requirements/test.txt index f1ab101..1ded7ef 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -4,39 +4,35 @@ # # make upgrade # -appdirs==1.4.3 # via virtualenv -astroid==2.3.3 # via pylint, pylint-celery +appdirs==1.4.4 # via virtualenv +astroid==2.4.2 # via pylint, pylint-celery click-log==0.3.2 # via edx-lint click==7.1.2 # via click-log, edx-lint -coverage==5.1 # via -r requirements/test.in -ddt==1.3.1 # via -r requirements/test.in -distlib==0.3.0 # via virtualenv -edx-lint==1.4.1 # via -r requirements/test.in -edx-opaque-keys==2.1.0 # via -r requirements/base.txt +coverage==5.3.1 # via -r requirements/test.in +ddt==1.4.1 # via -r requirements/test.in +distlib==0.3.1 # via virtualenv +edx-lint==1.6 # via -r requirements/test.in +edx-opaque-keys==2.1.1 # via -r requirements/base.txt filelock==3.0.12 # via tox, virtualenv -importlib-metadata==1.6.0 # via importlib-resources, pluggy, tox, virtualenv -importlib-resources==1.5.0 # via virtualenv -isort==4.3.21 # via pylint +isort==5.7.0 # via pylint lazy-object-proxy==1.4.3 # via -r requirements/test.in, astroid mccabe==0.6.1 # via pylint -mock==3.0.5 # via -r requirements/test.in +mock==4.0.3 # via -r requirements/test.in nose==1.3.7 # via -r requirements/test.in -packaging==20.3 # via tox -pbr==5.4.5 # via -r requirements/base.txt, stevedore +packaging==20.8 # via tox +pbr==5.5.1 # via -r requirements/base.txt, stevedore pluggy==0.13.1 # via tox -py==1.8.1 # via tox -pycodestyle==2.5.0 # via -r requirements/test.in +py==1.10.0 # via tox +pycodestyle==2.6.0 # via -r requirements/test.in pylint-celery==0.3 # via edx-lint -pylint-django==2.0.11 # via edx-lint +pylint-django==2.3.0 # via edx-lint pylint-plugin-utils==0.6 # via pylint-celery, pylint-django -pylint==2.4.2 # via edx-lint, pylint-celery, pylint-django, pylint-plugin-utils -pymongo==3.10.1 # via -r requirements/base.txt, edx-opaque-keys +pylint==2.6.0 # via edx-lint, pylint-celery, pylint-django, pylint-plugin-utils +pymongo==3.11.2 # via -r requirements/base.txt, edx-opaque-keys pyparsing==2.4.7 # via packaging -six==1.14.0 # via -r requirements/base.txt, astroid, edx-lint, edx-opaque-keys, mock, packaging, stevedore, tox, virtualenv -stevedore==1.32.0 # via -r requirements/base.txt, edx-opaque-keys -toml==0.10.0 # via tox -tox==3.15.0 # via -r requirements/test.in -typed-ast==1.4.1 # via astroid -virtualenv==20.0.20 # via tox -wrapt==1.11.2 # via astroid -zipp==1.2.0 # via importlib-metadata, importlib-resources +six==1.15.0 # via -r requirements/base.txt, astroid, edx-lint, edx-opaque-keys, tox, virtualenv +stevedore==3.3.0 # via -r requirements/base.txt, edx-opaque-keys +toml==0.10.2 # via pylint, tox +tox==3.21.0 # via -r requirements/test.in +virtualenv==20.3.0 # via tox +wrapt==1.12.1 # via astroid diff --git a/requirements/travis.txt b/requirements/travis.txt index b2f3930..d56955f 100644 --- a/requirements/travis.txt +++ b/requirements/travis.txt @@ -4,17 +4,14 @@ # # make upgrade # -appdirs==1.4.3 # via virtualenv -distlib==0.3.0 # via virtualenv +appdirs==1.4.4 # via virtualenv +distlib==0.3.1 # via virtualenv filelock==3.0.12 # via tox, virtualenv -importlib-metadata==1.6.0 # via importlib-resources, pluggy, tox, virtualenv -importlib-resources==1.5.0 # via virtualenv -packaging==20.3 # via tox +packaging==20.8 # via tox pluggy==0.13.1 # via tox -py==1.8.1 # via tox +py==1.10.0 # via tox pyparsing==2.4.7 # via packaging -six==1.14.0 # via packaging, tox, virtualenv -toml==0.10.0 # via tox -tox==3.15.0 # via -r requirements/travis.in -virtualenv==20.0.20 # via tox -zipp==1.2.0 # via importlib-metadata, importlib-resources +six==1.15.0 # via tox, virtualenv +toml==0.10.2 # via tox +tox==3.21.0 # via -r requirements/travis.in +virtualenv==20.3.0 # via tox diff --git a/setup.py b/setup.py index a583143..ecb2b8c 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,7 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """ Package metadata for edx-ccx-keys. """ -from io import open from setuptools import setup @@ -35,7 +33,7 @@ def is_requirement(line): setup( name='edx-ccx-keys', - version='1.1.0', + version='1.2.0', author='edX', author_email='oscm@edx.org', description='Opaque key support custom courses on edX', @@ -49,7 +47,6 @@ def is_requirement(line): 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.8', ], packages=[ diff --git a/tox.ini b/tox.ini index f25b51d..b95ec29 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,15 @@ [tox] -envlist = py{35,38},quality +envlist = py38,quality [testenv] -deps = - -r{toxinidir}/requirements/test.txt - -commands = - coverage run -m nose - coverage report -m +deps = + -r{toxinidir}/requirements/test.txt +commands = + coverage run -m nose + coverage report -m [testenv:quality] -commands = - pycodestyle --config=.pep8 ccx_keys - pylint --rcfile=pylintrc ccx_keys +commands = + pycodestyle --config=.pep8 ccx_keys + pylint --rcfile=pylintrc ccx_keys +