Skip to content

Commit

Permalink
Merge pull request #408 from akatsoulas/drop-py2
Browse files Browse the repository at this point in the history
Cleanup references of Python2
  • Loading branch information
akatsoulas committed Mar 22, 2021
2 parents 821de3d + 5f900ac commit 5d775a8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 26 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.7, and 3.4+, and for PyPy. Check
`<https://travis-ci.org/mozilla/mozilla-django-oidc/pull_requests>`_
3. The pull request should work for Python 3.6+ and for PyPy. Check
`<https://github.com/mozilla/mozilla-django-oidc/actions>`_
and make sure that the tests pass for all supported Python versions.

Tips
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ After installation, you'll need to do some things to get your site using
Requirements
------------

This library supports Python 2.7 and 3.3+ on OSX and Linux.
This library supports Python 3.6+ on OSX and Linux.


Acquire a client id and client secret
Expand Down
5 changes: 2 additions & 3 deletions mozilla_django_oidc/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import logging
import requests
import six
from requests.auth import HTTPBasicAuth

from django.contrib.auth import get_user_model
Expand Down Expand Up @@ -102,7 +101,7 @@ def get_username(self, claims):
username_algo = self.get_settings('OIDC_USERNAME_ALGO', None)

if username_algo:
if isinstance(username_algo, six.string_types):
if isinstance(username_algo, str):
username_algo = import_string(username_algo)
return username_algo(claims.get('email'))

Expand All @@ -127,7 +126,7 @@ def _verify_jws(self, payload, key):
"OIDC_RP_SIGN_ALGO.".format(alg)
raise SuspiciousOperation(msg)

if isinstance(key, six.string_types):
if isinstance(key, str):
# Use smart_bytes here since the key string comes from settings.
jwk = JWK.load(smart_bytes(key))
else:
Expand Down
13 changes: 4 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
history = open('HISTORY.rst').read().replace('.. :changelog:', '')

install_requirements = [
'Django >= 1.11',
'Django >= 2.2',
'josepy',
'requests',
'cryptography',
'six',
]

setup(
Expand All @@ -57,23 +56,19 @@
classifiers=[
'Development Status :: 5 - Production/Stable',
'Framework :: Django',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Intended Audience :: Developers',
'Operating System :: MacOS',
'Operating System :: POSIX :: Linux',
'Natural Language :: English',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
)
13 changes: 2 additions & 11 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import six
from mock import Mock, call, patch

from cryptography.hazmat.backends import default_backend
Expand Down Expand Up @@ -28,18 +27,10 @@ def run_test(self, data, expected):
self.assertEqual(type(actual), type(expected))

def test_empty(self):
if six.PY2:
self.run_test('', u'2jmj7l5rSw0yVb_vlWAYkK_YBwk')
self.run_test(u'', u'2jmj7l5rSw0yVb_vlWAYkK_YBwk')
else:
self.run_test('', '2jmj7l5rSw0yVb_vlWAYkK_YBwk')
self.run_test('', '2jmj7l5rSw0yVb_vlWAYkK_YBwk')

def test_email(self):
if six.PY2:
self.run_test('janet@example.com', u'VUCUpl08JVpFeAFKBYkAjLhsQ1c')
self.run_test(u'janet@example.com', u'VUCUpl08JVpFeAFKBYkAjLhsQ1c')
else:
self.run_test('janet@example.com', 'VUCUpl08JVpFeAFKBYkAjLhsQ1c')
self.run_test('janet@example.com', 'VUCUpl08JVpFeAFKBYkAjLhsQ1c')


class OIDCAuthenticationBackendTestCase(TestCase):
Expand Down

0 comments on commit 5d775a8

Please sign in to comment.