diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cfb389..817050d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: strategy: matrix: os: [ubuntu-20.04] - python-version: ['3.5', '3.8'] + python-version: ['3.8'] toxenv: ['django22', 'quality'] exclude: - - python-version: "3.5" + - python-version: "3.8" toxenv: "quality" steps: diff --git a/django_sites_extensions/middleware.py b/django_sites_extensions/middleware.py index 5c78789..36dfc26 100644 --- a/django_sites_extensions/middleware.py +++ b/django_sites_extensions/middleware.py @@ -18,7 +18,7 @@ def process_request(self, request): with the current request URL as the old_path field. """ site = request.site - cache_key = '{prefix}-{site}'.format(prefix=settings.REDIRECT_CACHE_KEY_PREFIX, site=site.domain) + cache_key = f'{settings.REDIRECT_CACHE_KEY_PREFIX}-{site.domain}' redirects = cache.get(cache_key) if redirects is None: redirects = {redirect.old_path: redirect.new_path for redirect in Redirect.objects.filter(site=site)} diff --git a/django_sites_extensions/signals.py b/django_sites_extensions/signals.py index f0781f4..21a9f16 100644 --- a/django_sites_extensions/signals.py +++ b/django_sites_extensions/signals.py @@ -15,5 +15,5 @@ def clear_redirect_cache(sender, instance, **kwargs): # pylint: disable=unused- """ Clears the Redirect cache """ - cache_key = '{prefix}-{site}'.format(prefix=settings.REDIRECT_CACHE_KEY_PREFIX, site=instance.site.domain) + cache_key = f'{settings.REDIRECT_CACHE_KEY_PREFIX}-{instance.site.domain}' cache.delete(cache_key) diff --git a/django_sites_extensions/tests/test_middleware.py b/django_sites_extensions/tests/test_middleware.py index ae2c569..0de3b14 100644 --- a/django_sites_extensions/tests/test_middleware.py +++ b/django_sites_extensions/tests/test_middleware.py @@ -15,7 +15,7 @@ class RedirectMiddlewareTestCase(TestCase): """ def setUp(self): - super(RedirectMiddlewareTestCase, self).setUp() + super().setUp() self.middleware = RedirectMiddleware() self.site = Site.objects.get(id=1) # pylint: disable=no-member self.redirect = Redirect.objects.create(site_id=1, old_path='/foo', new_path='http://example.com/bar') diff --git a/django_sites_extensions/tests/test_models.py b/django_sites_extensions/tests/test_models.py index 196fbfc..e9653d9 100644 --- a/django_sites_extensions/tests/test_models.py +++ b/django_sites_extensions/tests/test_models.py @@ -17,7 +17,7 @@ class PatchedSiteManagerTestCase(TestCase): """ def setUp(self): - super(PatchedSiteManagerTestCase, self).setUp() + super().setUp() self.foo_site = Site.objects.create(domain='foo.com') def test_site_cache_timeout_when_none(self): diff --git a/django_sites_extensions/tests/test_views.py b/django_sites_extensions/tests/test_views.py index 2ff0322..66461a9 100644 --- a/django_sites_extensions/tests/test_views.py +++ b/django_sites_extensions/tests/test_views.py @@ -12,7 +12,7 @@ class ViewsTestCase(TestCase): """ def setUp(self): - super(ViewsTestCase, self).setUp() + super().setUp() self.home_url = reverse('home') self.login_url = reverse('login') diff --git a/docs/conf.py b/docs/conf.py index e9c847d..59f32ab 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # edx-django-sites-extensions documentation build configuration file, created by # sphinx-quickstart on Sun Feb 17 11:46:20 2013. diff --git a/requirements/base.txt b/requirements/base.txt index c8ae728..79ffd15 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -4,6 +4,11 @@ # # make upgrade # -django==2.2.17 # via -c requirements/constraints.txt, -r requirements/base.in -pytz==2020.4 # via django -sqlparse==0.4.1 # via django +django==2.2.17 + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -r requirements/base.in +pytz==2020.5 + # via django +sqlparse==0.4.1 + # via django diff --git a/requirements/ci.txt b/requirements/ci.txt index 445e425..6aee880 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -4,24 +4,61 @@ # # make upgrade # -appdirs==1.4.4 # via -r requirements/tox.txt, virtualenv -certifi==2020.11.8 # via requests -chardet==3.0.4 # via requests -codecov==2.1.10 # via -r requirements/ci.in -coverage==5.3 # via codecov -distlib==0.3.1 # via -r requirements/tox.txt, virtualenv -filelock==3.0.12 # via -r requirements/tox.txt, tox, virtualenv -idna==2.10 # via requests -importlib-metadata==2.1.1 # via -r requirements/tox.txt, pluggy, tox, virtualenv -importlib-resources==3.2.1 # via -r requirements/tox.txt, virtualenv -packaging==20.7 # via -r requirements/tox.txt, tox -pluggy==0.13.1 # via -r requirements/tox.txt, tox -py==1.9.0 # via -r requirements/tox.txt, tox -pyparsing==2.4.7 # via -r requirements/tox.txt, packaging -requests==2.25.0 # via codecov -six==1.15.0 # via -r requirements/tox.txt, tox, virtualenv -toml==0.10.2 # via -r requirements/tox.txt, tox -tox==3.20.1 # via -r requirements/tox.txt -urllib3==1.26.2 # via requests -virtualenv==20.2.1 # via -r requirements/tox.txt, tox -zipp==1.2.0 # via -r requirements/tox.txt, importlib-metadata, importlib-resources +appdirs==1.4.4 + # via + # -r requirements/tox.txt + # virtualenv +certifi==2020.12.5 + # via requests +chardet==4.0.0 + # via requests +codecov==2.1.11 + # via -r requirements/ci.in +coverage==5.3.1 + # via codecov +distlib==0.3.1 + # via + # -r requirements/tox.txt + # virtualenv +filelock==3.0.12 + # via + # -r requirements/tox.txt + # tox + # virtualenv +idna==2.10 + # via requests +packaging==20.8 + # via + # -r requirements/tox.txt + # tox +pluggy==0.13.1 + # via + # -r requirements/tox.txt + # tox +py==1.10.0 + # via + # -r requirements/tox.txt + # tox +pyparsing==2.4.7 + # via + # -r requirements/tox.txt + # packaging +requests==2.25.1 + # via codecov +six==1.15.0 + # via + # -r requirements/tox.txt + # tox + # virtualenv +toml==0.10.2 + # via + # -r requirements/tox.txt + # tox +tox==3.21.2 + # via -r requirements/tox.txt +urllib3==1.26.2 + # via requests +virtualenv==20.4.0 + # via + # -r requirements/tox.txt + # tox diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 85f8812..f9ea41a 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -8,10 +8,5 @@ # pin when possible. Writing an issue against the offending project and # linking to it here is good. -# TODO: Many pinned dependencies should be unpinned and/or moved to this constraints file. - -# Use latest Django LTS version -Django>=2.2,<2.3.0 - -# mock version 4.0.0 drops support for python 3.5 -mock<4.0.0 +# This file contains all common constraints for edx-repos +-c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt diff --git a/requirements/django.txt b/requirements/django.txt index 076bb8d..34249f7 100644 --- a/requirements/django.txt +++ b/requirements/django.txt @@ -1 +1 @@ -django==2.2.17 # via -c requirements/constraints.txt, -r requirements/base.txt +django==2.2.17 diff --git a/requirements/doc.txt b/requirements/doc.txt index 18a633b..5473ce5 100644 --- a/requirements/doc.txt +++ b/requirements/doc.txt @@ -4,32 +4,64 @@ # # make upgrade # -alabaster==0.7.12 # via sphinx -babel==2.9.0 # via sphinx -certifi==2020.11.8 # via requests -chardet==3.0.4 # via requests -django==2.2.17 # via -c requirements/constraints.txt, -r requirements/base.in -docutils==0.16 # via sphinx -idna==2.10 # via requests -imagesize==1.2.0 # via sphinx -jinja2==2.11.2 # via sphinx -markupsafe==1.1.1 # via jinja2 -packaging==20.7 # via sphinx -pygments==2.7.2 # via sphinx -pyparsing==2.4.7 # via packaging -pytz==2020.4 # via babel, django -requests==2.25.0 # via sphinx -snowballstemmer==2.0.0 # via sphinx -sphinx-rtd-theme==0.5.0 # via -r requirements/doc.in -sphinx==3.3.1 # via -r requirements/doc.in, sphinx-rtd-theme -sphinxcontrib-applehelp==1.0.2 # via sphinx -sphinxcontrib-devhelp==1.0.2 # via sphinx -sphinxcontrib-htmlhelp==1.0.3 # via sphinx -sphinxcontrib-jsmath==1.0.1 # via sphinx -sphinxcontrib-qthelp==1.0.3 # via sphinx -sphinxcontrib-serializinghtml==1.1.4 # via sphinx -sqlparse==0.4.1 # via django -urllib3==1.26.2 # via requests +alabaster==0.7.12 + # via sphinx +babel==2.9.0 + # via sphinx +certifi==2020.12.5 + # via requests +chardet==4.0.0 + # via requests +django==2.2.17 + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -r requirements/base.in +docutils==0.16 + # via sphinx +idna==2.10 + # via requests +imagesize==1.2.0 + # via sphinx +jinja2==2.11.2 + # via sphinx +markupsafe==1.1.1 + # via jinja2 +packaging==20.8 + # via sphinx +pygments==2.7.4 + # via sphinx +pyparsing==2.4.7 + # via packaging +pytz==2020.5 + # via + # babel + # django +requests==2.25.1 + # via sphinx +snowballstemmer==2.0.0 + # via sphinx +sphinx-rtd-theme==0.5.1 + # via -r requirements/doc.in +sphinx==3.4.3 + # via + # -r requirements/doc.in + # sphinx-rtd-theme +sphinxcontrib-applehelp==1.0.2 + # via sphinx +sphinxcontrib-devhelp==1.0.2 + # via sphinx +sphinxcontrib-htmlhelp==1.0.3 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==1.0.3 + # via sphinx +sphinxcontrib-serializinghtml==1.1.4 + # via sphinx +sqlparse==0.4.1 + # via django +urllib3==1.26.2 + # via requests # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/requirements/pip.txt b/requirements/pip.txt index 7650aa5..884d847 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -4,8 +4,11 @@ # # make upgrade # -wheel==0.36.0 # via -r requirements/pip.in +wheel==0.36.2 + # via -r requirements/pip.in # The following packages are considered to be unsafe in a requirements file: -pip==20.3 # via -r requirements/pip.in -setuptools==50.3.2 # via -r requirements/pip.in +pip==20.3.3 + # via -r requirements/pip.in +setuptools==51.3.3 + # via -r requirements/pip.in diff --git a/requirements/pip_tools.txt b/requirements/pip_tools.txt index f3a39fc..53310ee 100644 --- a/requirements/pip_tools.txt +++ b/requirements/pip_tools.txt @@ -4,9 +4,10 @@ # # make upgrade # -click==7.1.2 # via pip-tools -pip-tools==5.4.0 # via -r requirements/pip_tools.in -six==1.15.0 # via pip-tools +click==7.1.2 + # 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 688b8a0..6f9c75a 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -4,53 +4,130 @@ # # make upgrade # -astroid==2.3.3 # via pylint, pylint-celery -attrs==20.3.0 # via pytest -bleach==3.2.1 # via readme-renderer -certifi==2020.11.8 # via requests -chardet==3.0.4 # via requests -click-log==0.3.2 # via edx-lint -click==7.1.2 # via click-log, edx-lint -coverage==5.3 # via -r requirements/test.in, pytest-cov -django-dynamic-fixture==3.1.1 # via -r requirements/test.in -docutils==0.16 # via readme-renderer -edx-lint==1.5.2 # via -r requirements/test.in -idna==2.10 # via requests -importlib-metadata==2.1.1 # via pluggy, pytest -iniconfig==1.1.1 # via pytest -isort==4.3.21 # via pylint -lazy-object-proxy==1.4.3 # via astroid -mccabe==0.6.1 # via pylint -mock==3.0.5 # via -c requirements/constraints.txt, -r requirements/test.in -packaging==20.7 # via bleach, pytest -pathlib2==2.3.5 # via pytest -pep8==1.7.1 # via -r requirements/test.in -pkginfo==1.6.1 # via twine -pluggy==0.13.1 # via pytest -py==1.9.0 # via pytest -pygments==2.7.2 # via readme-renderer -pylint-celery==0.3 # via edx-lint -pylint-django==2.0.11 # via edx-lint -pylint-plugin-utils==0.6 # via pylint-celery, pylint-django -pylint==2.4.4 # via edx-lint, pylint-celery, pylint-django, pylint-plugin-utils -pyparsing==2.4.7 # via packaging -pytest-cov==2.10.1 # via -r requirements/test.in -pytest-django==4.1.0 # via -r requirements/test.in -pytest==6.1.2 # via pytest-cov, pytest-django -pytz==2020.4 # via -r requirements/base.txt, django -readme-renderer==28.0 # via twine -requests-toolbelt==0.9.1 # via twine -requests==2.25.0 # via requests-toolbelt, twine -six==1.15.0 # via astroid, bleach, django-dynamic-fixture, edx-lint, mock, pathlib2, readme-renderer -sqlparse==0.4.1 # via -r requirements/base.txt, django -toml==0.10.2 # via pytest -tqdm==4.54.0 # via twine -twine==1.15.0 # via -r requirements/test.in -typed-ast==1.4.1 # via astroid -urllib3==1.26.2 # via requests -webencodings==0.5.1 # via bleach -wrapt==1.11.2 # via astroid -zipp==1.2.0 # via importlib-metadata +astroid==2.4.2 + # via + # pylint + # pylint-celery +attrs==20.3.0 + # via pytest +bleach==3.2.1 + # via readme-renderer +certifi==2020.12.5 + # via requests +chardet==4.0.0 + # via requests +click-log==0.3.2 + # via edx-lint +click==7.1.2 + # via + # click-log + # edx-lint +colorama==0.4.4 + # via twine +coverage==5.3.1 + # via + # -r requirements/test.in + # pytest-cov +django-dynamic-fixture==3.1.1 + # via -r requirements/test.in + # via + # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -r requirements/base.txt +docutils==0.16 + # via readme-renderer +edx-lint==1.6 + # via -r requirements/test.in +idna==2.10 + # via requests +iniconfig==1.1.1 + # via pytest +isort==5.7.0 + # via pylint +keyring==21.8.0 + # via twine +lazy-object-proxy==1.4.3 + # via astroid +mccabe==0.6.1 + # via pylint +mock==4.0.3 + # via -r requirements/test.in +packaging==20.8 + # via + # bleach + # pytest +pep8==1.7.1 + # via -r requirements/test.in +pkginfo==1.7.0 + # via twine +pluggy==0.13.1 + # via pytest +py==1.10.0 + # via pytest +pygments==2.7.4 + # via readme-renderer +pylint-celery==0.3 + # via edx-lint +pylint-django==2.3.0 + # via edx-lint +pylint-plugin-utils==0.6 + # via + # pylint-celery + # pylint-django +pylint==2.6.0 + # via + # edx-lint + # pylint-celery + # pylint-django + # pylint-plugin-utils +pyparsing==2.4.7 + # via packaging +pytest-cov==2.11.0 + # via -r requirements/test.in +pytest-django==4.1.0 + # via -r requirements/test.in +pytest==6.2.1 + # via + # pytest-cov + # pytest-django +pytz==2020.5 + # via + # -r requirements/base.txt + # django +readme-renderer==28.0 + # via twine +requests-toolbelt==0.9.1 + # via twine +requests==2.25.1 + # via + # requests-toolbelt + # twine +rfc3986==1.4.0 + # via twine +six==1.15.0 + # via + # astroid + # bleach + # django-dynamic-fixture + # edx-lint + # readme-renderer +sqlparse==0.4.1 + # via + # -r requirements/base.txt + # django +toml==0.10.2 + # via + # pylint + # pytest +tqdm==4.56.0 + # via twine +twine==3.3.0 + # via -r requirements/test.in +urllib3==1.26.2 + # via requests +webencodings==0.5.1 + # via bleach +wrapt==1.12.1 + # via astroid # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/requirements/tox.txt b/requirements/tox.txt index 1c7083b..b26ff81 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -4,17 +4,29 @@ # # make upgrade # -appdirs==1.4.4 # via virtualenv -distlib==0.3.1 # via virtualenv -filelock==3.0.12 # via tox, virtualenv -importlib-metadata==2.1.1 # via pluggy, tox, virtualenv -importlib-resources==3.2.1 # via virtualenv -packaging==20.7 # via tox -pluggy==0.13.1 # via tox -py==1.9.0 # via tox -pyparsing==2.4.7 # via packaging -six==1.15.0 # via tox, virtualenv -toml==0.10.2 # via tox -tox==3.20.1 # via -r requirements/tox.in -virtualenv==20.2.1 # via tox -zipp==1.2.0 # via importlib-metadata, importlib-resources +appdirs==1.4.4 + # via virtualenv +distlib==0.3.1 + # via virtualenv +filelock==3.0.12 + # via + # tox + # virtualenv +packaging==20.8 + # via tox +pluggy==0.13.1 + # via tox +py==1.10.0 + # via tox +pyparsing==2.4.7 + # via packaging +six==1.15.0 + # via + # tox + # virtualenv +toml==0.10.2 + # via tox +tox==3.21.2 + # via -r requirements/tox.in +virtualenv==20.4.0 + # via tox diff --git a/setup.py b/setup.py index 6612698..368ba2e 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ from setuptools import setup -with io.open('README.rst', encoding='utf-8') as readme: +with open('README.rst', encoding='utf-8') as readme: long_description = readme.read() def load_requirements(*requirements_paths): @@ -34,14 +34,13 @@ def is_requirement(line): setup( name='edx-django-sites-extensions', - version='2.5.1', + version='3.0.0', description='Custom extensions for the Django sites framework', long_description=long_description, classifiers=[ 'Development Status :: 4 - Beta', 'License :: OSI Approved :: GNU Affero General Public License v3', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.8', 'Topic :: Internet', 'Intended Audience :: Developers', diff --git a/tox.ini b/tox.ini index 4917bc2..1070ee3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,24 +1,22 @@ [tox] -envlist = python{3.5}-django22,python{3.8}-django{22,30,31},quality,docs +envlist = python{3.8}-django{22,30,31},quality,docs [testenv] -setenv = - # This allows us to reference test_settings.py - PYTHONPATH = {toxinidir} - DJANGO_SETTINGS_MODULE = test_settings - -deps = - django22: -rrequirements/django.txt - django30: Django>=3.0,<3.1 - django31: Django>=3.1,<3.2 - -r requirements/test.txt - -commands = - pytest --cov=django_sites_extensions +setenv = + PYTHONPATH = {toxinidir} + DJANGO_SETTINGS_MODULE = test_settings +deps = + django22: Django>=2.2,<2.3 + django30: Django>=3.0,<3.1 + django31: Django>=3.1,<3.2 + -r requirements/test.txt +commands = + pytest --cov=django_sites_extensions [testenv:quality] -commands = - pep8 --config=.pep8 django_sites_extensions - pylint --rcfile pylintrc django_sites_extensions - python setup.py bdist_wheel - twine check dist/* +commands = + pep8 --config=.pep8 django_sites_extensions + pylint --rcfile pylintrc django_sites_extensions + python setup.py bdist_wheel + twine check dist/* +