Skip to content

Commit

Permalink
Merge pull request #32 from edx/jenkins/cleanup-python-code-30d7a33
Browse files Browse the repository at this point in the history
Python Code Cleanup
  • Loading branch information
awais786 authored Jan 20, 2021
2 parents 30d7a33 + 731d435 commit da9b0e3
Show file tree
Hide file tree
Showing 18 changed files with 313 additions and 155 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion django_sites_extensions/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
2 changes: 1 addition & 1 deletion django_sites_extensions/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion django_sites_extensions/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion django_sites_extensions/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion django_sites_extensions/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
11 changes: 8 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
79 changes: 58 additions & 21 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 2 additions & 7 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion requirements/django.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
django==2.2.17 # via -c requirements/constraints.txt, -r requirements/base.txt
django==2.2.17
84 changes: 58 additions & 26 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions requirements/pip_tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit da9b0e3

Please sign in to comment.