From ddc953c11e8d79607f5931a2f80dcd9f7a10c5d9 Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 14 Aug 2019 23:33:19 +0300 Subject: sudo no longer needed https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f2e68a6..76b0649 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: python python: 3.7 dist: xenial -sudo: false cache: pip matrix: include: -- cgit v1.2.1 From 3718a0e048e64994c2ee3819c5e5ed218a05f115 Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 14 Aug 2019 23:35:36 +0300 Subject: Drop support for legacy Python 2.7 --- .travis.yml | 2 - README.rst | 2 +- bandit.json | 2 +- docs/contributing.rst | 4 +- oauthlib/common.py | 41 ++++-------------- oauthlib/oauth1/rfc5849/signature.py | 7 ++- oauthlib/oauth1/rfc5849/utils.py | 6 +-- oauthlib/oauth2/rfc6749/endpoints/metadata.py | 3 +- oauthlib/oauth2/rfc6749/parameters.py | 12 +++--- oauthlib/oauth2/rfc6749/tokens.py | 4 +- oauthlib/oauth2/rfc6749/utils.py | 12 +++--- oauthlib/openid/connect/core/endpoints/userinfo.py | 3 +- setup.py | 5 +-- tests/oauth1/rfc5849/test_signatures.py | 3 +- tests/oauth1/rfc5849/test_utils.py | 9 ++-- .../rfc6749/endpoints/test_scope_handling.py | 6 +-- tests/oauth2/rfc6749/test_utils.py | 9 +--- tests/test_common.py | 50 +++++++++++----------- tests/unittest/__init__.py | 21 +++------ tox.ini | 4 +- 20 files changed, 79 insertions(+), 126 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76b0649..c7ec677 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,6 @@ dist: xenial cache: pip matrix: include: - - python: 2.7 - env: TOXENV=py27 - python: 3.4 env: TOXENV=py34 - python: 3.5 diff --git a/README.rst b/README.rst index 2900ecc..48b9853 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ OAuthLib - Python Framework for OAuth1 & OAuth2 =============================================== *A generic, spec-compliant, thorough implementation of the OAuth request-signing -logic for Python 2.7 and 3.4+.* +logic for Python 3.4+.* .. image:: https://travis-ci.org/oauthlib/oauthlib.svg?branch=master :target: https://travis-ci.org/oauthlib/oauthlib diff --git a/bandit.json b/bandit.json index 4d3bfe1..7161f00 100644 --- a/bandit.json +++ b/bandit.json @@ -1133,7 +1133,7 @@ "test_name": "hardcoded_password_funcarg" }, { - "code": "164 \n165 def prepare_token_revocation_request(url, token, token_type_hint=\"access_token\",\n166 callback=None, body='', **kwargs):\n167 \"\"\"Prepare a token revocation request.\n168 \n169 The client constructs the request by including the following parameters\n170 using the \"application/x-www-form-urlencoded\" format in the HTTP request\n171 entity-body:\n172 \n173 :param token: REQUIRED. The token that the client wants to get revoked.\n174 \n175 :param token_type_hint: OPTIONAL. A hint about the type of the token\n176 submitted for revocation. Clients MAY pass this\n177 parameter in order to help the authorization server\n178 to optimize the token lookup. If the server is\n179 unable to locate the token using the given hint, it\n180 MUST extend its search across all of its supported\n181 token types. An authorization server MAY ignore\n182 this parameter, particularly if it is able to detect\n183 the token type automatically.\n184 \n185 This specification defines two values for `token_type_hint`:\n186 \n187 * access_token: An access token as defined in [RFC6749],\n188 `Section 1.4`_\n189 \n190 * refresh_token: A refresh token as defined in [RFC6749],\n191 `Section 1.5`_\n192 \n193 Specific implementations, profiles, and extensions of this\n194 specification MAY define other values for this parameter using the\n195 registry defined in `Section 4.1.2`_.\n196 \n197 .. _`Section 1.4`: https://tools.ietf.org/html/rfc6749#section-1.4\n198 .. _`Section 1.5`: https://tools.ietf.org/html/rfc6749#section-1.5\n199 .. _`Section 4.1.2`: https://tools.ietf.org/html/rfc7009#section-4.1.2\n200 \n201 \"\"\"\n202 if not is_secure_transport(url):\n203 raise InsecureTransportError()\n204 \n205 params = [('token', token)]\n206 \n207 if token_type_hint:\n208 params.append(('token_type_hint', token_type_hint))\n209 \n210 for k in kwargs:\n211 if kwargs[k]:\n212 params.append((unicode_type(k), kwargs[k]))\n213 \n214 headers = {'Content-Type': 'application/x-www-form-urlencoded'}\n215 \n216 if callback:\n217 params.append(('callback', callback))\n218 return add_params_to_uri(url, params), headers, body\n219 else:\n220 return url, headers, add_params_to_qs(body, params)\n221 \n222 \n223 def parse_authorization_code_response(uri, state=None):\n", + "code": "164 \n165 def prepare_token_revocation_request(url, token, token_type_hint=\"access_token\",\n166 callback=None, body='', **kwargs):\n167 \"\"\"Prepare a token revocation request.\n168 \n169 The client constructs the request by including the following parameters\n170 using the \"application/x-www-form-urlencoded\" format in the HTTP request\n171 entity-body:\n172 \n173 :param token: REQUIRED. The token that the client wants to get revoked.\n174 \n175 :param token_type_hint: OPTIONAL. A hint about the type of the token\n176 submitted for revocation. Clients MAY pass this\n177 parameter in order to help the authorization server\n178 to optimize the token lookup. If the server is\n179 unable to locate the token using the given hint, it\n180 MUST extend its search across all of its supported\n181 token types. An authorization server MAY ignore\n182 this parameter, particularly if it is able to detect\n183 the token type automatically.\n184 \n185 This specification defines two values for `token_type_hint`:\n186 \n187 * access_token: An access token as defined in [RFC6749],\n188 `Section 1.4`_\n189 \n190 * refresh_token: A refresh token as defined in [RFC6749],\n191 `Section 1.5`_\n192 \n193 Specific implementations, profiles, and extensions of this\n194 specification MAY define other values for this parameter using the\n195 registry defined in `Section 4.1.2`_.\n196 \n197 .. _`Section 1.4`: https://tools.ietf.org/html/rfc6749#section-1.4\n198 .. _`Section 1.5`: https://tools.ietf.org/html/rfc6749#section-1.5\n199 .. _`Section 4.1.2`: https://tools.ietf.org/html/rfc7009#section-4.1.2\n200 \n201 \"\"\"\n202 if not is_secure_transport(url):\n203 raise InsecureTransportError()\n204 \n205 params = [('token', token)]\n206 \n207 if token_type_hint:\n208 params.append(('token_type_hint', token_type_hint))\n209 \n210 for k in kwargs:\n211 if kwargs[k]:\n212 params.append((str(k), kwargs[k]))\n213 \n214 headers = {'Content-Type': 'application/x-www-form-urlencoded'}\n215 \n216 if callback:\n217 params.append(('callback', callback))\n218 return add_params_to_uri(url, params), headers, body\n219 else:\n220 return url, headers, add_params_to_qs(body, params)\n221 \n222 \n223 def parse_authorization_code_response(uri, state=None):\n", "filename": "oauthlib/oauth2/rfc6749/parameters.py", "issue_confidence": "MEDIUM", "issue_severity": "LOW", diff --git a/docs/contributing.rst b/docs/contributing.rst index e101f70..93f6a81 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -152,7 +152,7 @@ request that fails this test suite will be **rejected**. Testing multiple versions of Python ----------------------------------- -OAuthLib supports Python 2.7, 3.4, 3.5, 3.6 and PyPy. Testing +OAuthLib supports Python 3.4, 3.5, 3.6 and PyPy. Testing all versions conveniently can be done using `Tox`_. .. sourcecode:: bash @@ -166,8 +166,6 @@ version. For Ubuntu you can easily install all after adding one ppa. $ sudo add-apt-repository ppa:fkrull/deadsnakes $ sudo apt-get update - $ sudo apt-get install python2.6 python2.6-dev - $ sudo apt-get install python2.7 python2.7-dev $ sudo apt-get install python3.2 python3.2-dev $ sudo apt-get install python3.3 python3.3-dev $ sudo apt-get install pypy pypy-dev diff --git a/oauthlib/common.py b/oauthlib/common.py index 5aeb015..1462e75 100644 --- a/oauthlib/common.py +++ b/oauthlib/common.py @@ -51,17 +51,10 @@ always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' log = logging.getLogger('oauthlib') -PY3 = sys.version_info[0] == 3 - -if PY3: - unicode_type = str -else: - unicode_type = unicode - # 'safe' must be bytes (Python 2.6 requires bytes, other versions allow either) def quote(s, safe=b'/'): - s = s.encode('utf-8') if isinstance(s, unicode_type) else s + s = s.encode('utf-8') if isinstance(s, str) else s s = _quote(s, safe) # PY3 always returns unicode. PY2 may return either, depending on whether # it had to modify the string. @@ -83,7 +76,7 @@ def unquote(s): def urlencode(params): utf8_params = encode_params_utf8(params) urlencoded = _urlencode(utf8_params) - if isinstance(urlencoded, unicode_type): # PY3 returns unicode + if isinstance(urlencoded, str): return urlencoded else: return urlencoded.decode("utf-8") @@ -96,8 +89,8 @@ def encode_params_utf8(params): encoded = [] for k, v in params: encoded.append(( - k.encode('utf-8') if isinstance(k, unicode_type) else k, - v.encode('utf-8') if isinstance(v, unicode_type) else v)) + k.encode('utf-8') if isinstance(k, str) else k, + v.encode('utf-8') if isinstance(v, str) else v)) return encoded @@ -141,22 +134,6 @@ def urldecode(query): if INVALID_HEX_PATTERN.search(query): raise ValueError('Invalid hex encoding in query string.') - # We encode to utf-8 prior to parsing because parse_qsl behaves - # differently on unicode input in python 2 and 3. - # Python 2.7 - # >>> urlparse.parse_qsl(u'%E5%95%A6%E5%95%A6') - # u'\xe5\x95\xa6\xe5\x95\xa6' - # Python 2.7, non unicode input gives the same - # >>> urlparse.parse_qsl('%E5%95%A6%E5%95%A6') - # '\xe5\x95\xa6\xe5\x95\xa6' - # but now we can decode it to unicode - # >>> urlparse.parse_qsl('%E5%95%A6%E5%95%A6').decode('utf-8') - # u'\u5566\u5566' - # Python 3.3 however - # >>> urllib.parse.parse_qsl(u'%E5%95%A6%E5%95%A6') - # u'\u5566\u5566' - query = query.encode( - 'utf-8') if not PY3 and isinstance(query, unicode_type) else query # We want to allow queries such as "c2" whereas urlparse.parse_qsl # with the strict_parsing flag will not. params = urlparse.parse_qsl(query, keep_blank_values=True) @@ -173,7 +150,7 @@ def extract_params(raw): empty list of parameters. Any other input will result in a return value of None. """ - if isinstance(raw, (bytes, unicode_type)): + if isinstance(raw, (bytes, str)): try: params = urldecode(raw) except ValueError: @@ -206,7 +183,7 @@ def generate_nonce(): .. _`section 3.2.1`: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1 .. _`section 3.3`: https://tools.ietf.org/html/rfc5849#section-3.3 """ - return unicode_type(unicode_type(randbits(64)) + generate_timestamp()) + return str(str(randbits(64)) + generate_timestamp()) def generate_timestamp(): @@ -218,7 +195,7 @@ def generate_timestamp(): .. _`section 3.2.1`: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1 .. _`section 3.3`: https://tools.ietf.org/html/rfc5849#section-3.3 """ - return unicode_type(int(time.time())) + return str(int(time.time())) def generate_token(length=30, chars=UNICODE_ASCII_CHARACTER_SET): @@ -305,11 +282,11 @@ def safe_string_equals(a, b): def to_unicode(data, encoding='UTF-8'): """Convert a number of different types of objects to unicode.""" - if isinstance(data, unicode_type): + if isinstance(data, str): return data if isinstance(data, bytes): - return unicode_type(data, encoding=encoding) + return str(data, encoding=encoding) if hasattr(data, '__iter__'): try: diff --git a/oauthlib/oauth1/rfc5849/signature.py b/oauthlib/oauth1/rfc5849/signature.py index a60bee2..5b080aa 100644 --- a/oauthlib/oauth1/rfc5849/signature.py +++ b/oauthlib/oauth1/rfc5849/signature.py @@ -28,8 +28,7 @@ import hashlib import hmac import logging -from oauthlib.common import (extract_params, safe_string_equals, - unicode_type, urldecode) +from oauthlib.common import extract_params, safe_string_equals, urldecode from . import utils @@ -128,7 +127,7 @@ def base_string_uri(uri, host=None): The host argument overrides the netloc part of the uri argument. """ - if not isinstance(uri, unicode_type): + if not isinstance(uri, str): raise ValueError('uri must be a unicode object.') # FIXME: urlparse does not support unicode @@ -577,7 +576,7 @@ def sign_rsa_sha1(base_string, rsa_private_key): .. _`RFC3447, Section 8.2`: https://tools.ietf.org/html/rfc3447#section-8.2 """ - if isinstance(base_string, unicode_type): + if isinstance(base_string, str): base_string = base_string.encode('utf-8') # TODO: finish RSA documentation alg = _jwt_rs1_signing_algorithm() diff --git a/oauthlib/oauth1/rfc5849/utils.py b/oauthlib/oauth1/rfc5849/utils.py index 735f21d..a010aea 100644 --- a/oauthlib/oauth1/rfc5849/utils.py +++ b/oauthlib/oauth1/rfc5849/utils.py @@ -8,7 +8,7 @@ spec. """ from __future__ import absolute_import, unicode_literals -from oauthlib.common import quote, unicode_type, unquote +from oauthlib.common import quote, unquote try: import urllib2 @@ -52,7 +52,7 @@ def escape(u): .. _`section 3.6`: https://tools.ietf.org/html/rfc5849#section-3.6 """ - if not isinstance(u, unicode_type): + if not isinstance(u, str): raise ValueError('Only unicode objects are escapable. ' + 'Got %r of type %s.' % (u, type(u))) # Letters, digits, and the characters '_.-' are already treated as safe @@ -61,7 +61,7 @@ def escape(u): def unescape(u): - if not isinstance(u, unicode_type): + if not isinstance(u, str): raise ValueError('Only unicode objects are unescapable.') return unquote(u) diff --git a/oauthlib/oauth2/rfc6749/endpoints/metadata.py b/oauthlib/oauth2/rfc6749/endpoints/metadata.py index 936e878..d3ff1d7 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/metadata.py +++ b/oauthlib/oauth2/rfc6749/endpoints/metadata.py @@ -13,7 +13,6 @@ import copy import json import logging -from ....common import unicode_type from .base import BaseEndpoint, catch_errors_and_unavailability from .authorization import AuthorizationEndpoint from .introspect import IntrospectEndpoint @@ -85,7 +84,7 @@ class MetadataEndpoint(BaseEndpoint): if not isinstance(array[key], list): raise ValueError("key {}: {} must be an Array".format(key, array[key])) for elem in array[key]: - if not isinstance(elem, unicode_type): + if not isinstance(elem, str): raise ValueError("array {}: {} must contains only string (not {})".format(key, array[key], elem)) def validate_metadata_token(self, claims, endpoint): diff --git a/oauthlib/oauth2/rfc6749/parameters.py b/oauthlib/oauth2/rfc6749/parameters.py index 14d4c0d..b6249d8 100644 --- a/oauthlib/oauth2/rfc6749/parameters.py +++ b/oauthlib/oauth2/rfc6749/parameters.py @@ -13,7 +13,7 @@ import json import os import time -from oauthlib.common import add_params_to_qs, add_params_to_uri, unicode_type +from oauthlib.common import add_params_to_qs, add_params_to_uri from oauthlib.signals import scope_changed from .errors import (InsecureTransportError, MismatchingStateError, @@ -82,7 +82,7 @@ def prepare_grant_uri(uri, client_id, response_type, redirect_uri=None, for k in kwargs: if kwargs[k]: - params.append((unicode_type(k), kwargs[k])) + params.append((str(k), kwargs[k])) return add_params_to_uri(uri, params) @@ -146,18 +146,18 @@ def prepare_token_request(grant_type, body='', include_client_id=True, **kwargs) client_id = kwargs.pop('client_id', None) if include_client_id: if client_id is not None: - params.append((unicode_type('client_id'), client_id)) + params.append((str('client_id'), client_id)) # the kwargs iteration below only supports including boolean truth (truthy) # values, but some servers may require an empty string for `client_secret` client_secret = kwargs.pop('client_secret', None) if client_secret is not None: - params.append((unicode_type('client_secret'), client_secret)) + params.append((str('client_secret'), client_secret)) # this handles: `code`, `redirect_uri`, and other undocumented params for k in kwargs: if kwargs[k]: - params.append((unicode_type(k), kwargs[k])) + params.append((str(k), kwargs[k])) return add_params_to_qs(body, params) @@ -209,7 +209,7 @@ def prepare_token_revocation_request(url, token, token_type_hint="access_token", for k in kwargs: if kwargs[k]: - params.append((unicode_type(k), kwargs[k])) + params.append((str(k), kwargs[k])) headers = {'Content-Type': 'application/x-www-form-urlencoded'} diff --git a/oauthlib/oauth2/rfc6749/tokens.py b/oauthlib/oauth2/rfc6749/tokens.py index 3587af4..5b99f0c 100644 --- a/oauthlib/oauth2/rfc6749/tokens.py +++ b/oauthlib/oauth2/rfc6749/tokens.py @@ -15,7 +15,7 @@ from binascii import b2a_base64 import warnings from oauthlib import common -from oauthlib.common import add_params_to_qs, add_params_to_uri, unicode_type +from oauthlib.common import add_params_to_qs, add_params_to_uri from . import utils @@ -158,7 +158,7 @@ def prepare_mac_header(token, uri, key, http_method, base_string = '\n'.join(base) + '\n' # hmac struggles with unicode strings - http://bugs.python.org/issue5285 - if isinstance(key, unicode_type): + if isinstance(key, str): key = key.encode('utf-8') sign = hmac.new(key, base_string.encode('utf-8'), h) sign = b2a_base64(sign.digest())[:-1].decode('utf-8') diff --git a/oauthlib/oauth2/rfc6749/utils.py b/oauthlib/oauth2/rfc6749/utils.py index f67019d..7516c9e 100644 --- a/oauthlib/oauth2/rfc6749/utils.py +++ b/oauthlib/oauth2/rfc6749/utils.py @@ -10,7 +10,7 @@ from __future__ import absolute_import, unicode_literals import datetime import os -from oauthlib.common import unicode_type, urldecode +from oauthlib.common import urldecode try: from urllib import quote @@ -24,10 +24,10 @@ except ImportError: def list_to_scope(scope): """Convert a list of scopes to a space separated string.""" - if isinstance(scope, unicode_type) or scope is None: + if isinstance(scope, str) or scope is None: return scope elif isinstance(scope, (set, tuple, list)): - return " ".join([unicode_type(s) for s in scope]) + return " ".join([str(s) for s in scope]) else: raise ValueError("Invalid scope (%s), must be string, tuple, set, or list." % scope) @@ -35,7 +35,7 @@ def list_to_scope(scope): def scope_to_list(scope): """Convert a space separated string to a list of scopes.""" if isinstance(scope, (tuple, list, set)): - return [unicode_type(s) for s in scope] + return [str(s) for s in scope] elif scope is None: return None else: @@ -74,7 +74,7 @@ def escape(u): TODO: verify whether this can in fact be used for OAuth 2 """ - if not isinstance(u, unicode_type): + if not isinstance(u, str): raise ValueError('Only unicode objects are escapable.') return quote(u.encode('utf-8'), safe=b'~') @@ -84,7 +84,7 @@ def generate_age(issue_time): td = datetime.datetime.now() - issue_time age = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6) / 10 ** 6 - return unicode_type(age) + return str(age) def is_secure_transport(uri): diff --git a/oauthlib/openid/connect/core/endpoints/userinfo.py b/oauthlib/openid/connect/core/endpoints/userinfo.py index 7a39f76..d7387fe 100644 --- a/oauthlib/openid/connect/core/endpoints/userinfo.py +++ b/oauthlib/openid/connect/core/endpoints/userinfo.py @@ -10,7 +10,6 @@ import json import logging from oauthlib.common import Request -from oauthlib.common import unicode_type from oauthlib.oauth2.rfc6749.endpoints.base import BaseEndpoint from oauthlib.oauth2.rfc6749.endpoints.base import catch_errors_and_unavailability from oauthlib.oauth2.rfc6749.tokens import BearerToken @@ -55,7 +54,7 @@ class UserInfoEndpoint(BaseEndpoint): log.error('Userinfo MUST have "sub" for %r.', request) raise errors.ServerError(status_code=500) body = json.dumps(claims) - elif isinstance(claims, unicode_type): + elif isinstance(claims, str): resp_headers = { 'Content-Type': 'application/jwt' } diff --git a/setup.py b/setup.py index 1de8510..0aebd6c 100755 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ setup( platforms='any', license='BSD', packages=find_packages(exclude=('docs', 'tests', 'tests.*')), - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', + python_requires='>=3.4', extras_require={ 'rsa': rsa_require, 'signedtoken': signedtoken_require, @@ -53,13 +53,12 @@ setup( 'Operating System :: POSIX', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python', - '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.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: Implementation', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', diff --git a/tests/oauth1/rfc5849/test_signatures.py b/tests/oauth1/rfc5849/test_signatures.py index bb0dc78..4eb7ff3 100644 --- a/tests/oauth1/rfc5849/test_signatures.py +++ b/tests/oauth1/rfc5849/test_signatures.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals -from oauthlib.common import unicode_type from oauthlib.oauth1.rfc5849.signature import (collect_parameters, signature_base_string, base_string_uri, @@ -232,7 +231,7 @@ class SignatureTests(TestCase): normalized = normalize_parameters(parameters) # Unicode everywhere and always - self.assertIsInstance(normalized, unicode_type) + self.assertIsInstance(normalized, str) # Lets see if things are in order # check to see that querystring keys come in alphanumeric order: diff --git a/tests/oauth1/rfc5849/test_utils.py b/tests/oauth1/rfc5849/test_utils.py index 5a889e8..1db2659 100644 --- a/tests/oauth1/rfc5849/test_utils.py +++ b/tests/oauth1/rfc5849/test_utils.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals -from oauthlib.common import unicode_type from oauthlib.oauth1.rfc5849.utils import * from ...unittest import TestCase @@ -102,12 +101,12 @@ class UtilsTests(TestCase): def test_escape(self): self.assertRaises(ValueError, escape, b"I am a string type. Not a unicode type.") self.assertEqual(escape("I am a unicode type."), "I%20am%20a%20unicode%20type.") - self.assertIsInstance(escape("I am a unicode type."), unicode_type) + self.assertIsInstance(escape("I am a unicode type."), str) def test_unescape(self): self.assertRaises(ValueError, unescape, b"I am a string type. Not a unicode type.") self.assertEqual(unescape("I%20am%20a%20unicode%20type."), 'I am a unicode type.') - self.assertIsInstance(unescape("I%20am%20a%20unicode%20type."), unicode_type) + self.assertIsInstance(unescape("I%20am%20a%20unicode%20type."), str) def test_parse_authorization_header(self): # make us some headers @@ -122,8 +121,8 @@ class UtilsTests(TestCase): # are the internal components of each tuple unicode? for k, v in authorization_headers: - self.assertIsInstance(k, unicode_type) - self.assertIsInstance(v, unicode_type) + self.assertIsInstance(k, str) + self.assertIsInstance(v, str) # let's check the parsed headers created correct_headers = [ diff --git a/tests/oauth2/rfc6749/endpoints/test_scope_handling.py b/tests/oauth2/rfc6749/endpoints/test_scope_handling.py index 4f27963..b235bd7 100644 --- a/tests/oauth2/rfc6749/endpoints/test_scope_handling.py +++ b/tests/oauth2/rfc6749/endpoints/test_scope_handling.py @@ -65,13 +65,13 @@ class TestScopeHandling(TestCase): for scope, correct_scopes in scopes: scopes, _ = self.web.validate_authorization_request( uri % (scope, 'code')) - self.assertItemsEqual(scopes, correct_scopes) + self.assertCountEqual(scopes, correct_scopes) scopes, _ = self.mobile.validate_authorization_request( uri % (scope, 'token')) - self.assertItemsEqual(scopes, correct_scopes) + self.assertCountEqual(scopes, correct_scopes) scopes, _ = self.server.validate_authorization_request( uri % (scope, 'code')) - self.assertItemsEqual(scopes, correct_scopes) + self.assertCountEqual(scopes, correct_scopes) def test_scope_preservation(self): scope = 'pics+http%3A%2f%2fa.b%2fvideos' diff --git a/tests/oauth2/rfc6749/test_utils.py b/tests/oauth2/rfc6749/test_utils.py index 609162c..6b85b27 100644 --- a/tests/oauth2/rfc6749/test_utils.py +++ b/tests/oauth2/rfc6749/test_utils.py @@ -3,7 +3,6 @@ from __future__ import absolute_import, unicode_literals import datetime import os -from oauthlib.common import PY3 from oauthlib.oauth2.rfc6749.utils import (escape, generate_age, host_from_uri, is_secure_transport, list_to_scope, params_from_uri, scope_to_list) @@ -19,12 +18,8 @@ class ScopeObject: def __init__(self, scope): self.scope = scope - if PY3: - def __str__(self): - return self.scope - else: - def __unicode__(self): - return self.scope + def __str__(self): + return self.scope class UtilsTests(TestCase): diff --git a/tests/test_common.py b/tests/test_common.py index ae2531b..c2c5e41 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -8,7 +8,7 @@ import oauthlib from oauthlib.common import (CaseInsensitiveDict, Request, add_params_to_uri, extract_params, generate_client_id, generate_nonce, generate_timestamp, - generate_token, unicode_type, urldecode) + generate_token, urldecode) from .unittest import TestCase @@ -21,23 +21,23 @@ URI = 'http://www.someuri.com' class EncodingTest(TestCase): def test_urldecode(self): - self.assertItemsEqual(urldecode(''), []) - self.assertItemsEqual(urldecode('='), [('', '')]) - self.assertItemsEqual(urldecode('%20'), [(' ', '')]) - self.assertItemsEqual(urldecode('+'), [(' ', '')]) - self.assertItemsEqual(urldecode('c2'), [('c2', '')]) - self.assertItemsEqual(urldecode('c2='), [('c2', '')]) - self.assertItemsEqual(urldecode('foo=bar'), [('foo', 'bar')]) - self.assertItemsEqual(urldecode('foo_%20~=.bar-'), + self.assertCountEqual(urldecode(''), []) + self.assertCountEqual(urldecode('='), [('', '')]) + self.assertCountEqual(urldecode('%20'), [(' ', '')]) + self.assertCountEqual(urldecode('+'), [(' ', '')]) + self.assertCountEqual(urldecode('c2'), [('c2', '')]) + self.assertCountEqual(urldecode('c2='), [('c2', '')]) + self.assertCountEqual(urldecode('foo=bar'), [('foo', 'bar')]) + self.assertCountEqual(urldecode('foo_%20~=.bar-'), [('foo_ ~', '.bar-')]) - self.assertItemsEqual(urldecode('foo=1,2,3'), [('foo', '1,2,3')]) - self.assertItemsEqual(urldecode('foo=(1,2,3)'), [('foo', '(1,2,3)')]) - self.assertItemsEqual(urldecode('foo=bar.*'), [('foo', 'bar.*')]) - self.assertItemsEqual(urldecode('foo=bar@spam'), [('foo', 'bar@spam')]) - self.assertItemsEqual(urldecode('foo=bar/baz'), [('foo', 'bar/baz')]) - self.assertItemsEqual(urldecode('foo=bar?baz'), [('foo', 'bar?baz')]) - self.assertItemsEqual(urldecode('foo=bar\'s'), [('foo', 'bar\'s')]) - self.assertItemsEqual(urldecode('foo=$'), [('foo', '$')]) + self.assertCountEqual(urldecode('foo=1,2,3'), [('foo', '1,2,3')]) + self.assertCountEqual(urldecode('foo=(1,2,3)'), [('foo', '(1,2,3)')]) + self.assertCountEqual(urldecode('foo=bar.*'), [('foo', 'bar.*')]) + self.assertCountEqual(urldecode('foo=bar@spam'), [('foo', 'bar@spam')]) + self.assertCountEqual(urldecode('foo=bar/baz'), [('foo', 'bar/baz')]) + self.assertCountEqual(urldecode('foo=bar?baz'), [('foo', 'bar?baz')]) + self.assertCountEqual(urldecode('foo=bar\'s'), [('foo', 'bar\'s')]) + self.assertCountEqual(urldecode('foo=$'), [('foo', '$')]) self.assertRaises(ValueError, urldecode, 'foo bar') self.assertRaises(ValueError, urldecode, '%R') self.assertRaises(ValueError, urldecode, '%RA') @@ -48,20 +48,20 @@ class EncodingTest(TestCase): class ParameterTest(TestCase): def test_extract_params_dict(self): - self.assertItemsEqual(extract_params(PARAMS_DICT), PARAMS_TWOTUPLE) + self.assertCountEqual(extract_params(PARAMS_DICT), PARAMS_TWOTUPLE) def test_extract_params_twotuple(self): - self.assertItemsEqual(extract_params(PARAMS_TWOTUPLE), PARAMS_TWOTUPLE) + self.assertCountEqual(extract_params(PARAMS_TWOTUPLE), PARAMS_TWOTUPLE) def test_extract_params_formencoded(self): - self.assertItemsEqual(extract_params(PARAMS_FORMENCODED), + self.assertCountEqual(extract_params(PARAMS_FORMENCODED), PARAMS_TWOTUPLE) def test_extract_params_blank_string(self): - self.assertItemsEqual(extract_params(''), []) + self.assertCountEqual(extract_params(''), []) def test_extract_params_empty_list(self): - self.assertItemsEqual(extract_params([]), []) + self.assertCountEqual(extract_params([]), []) def test_extract_non_formencoded_string(self): self.assertEqual(extract_params('not a formencoded string'), None) @@ -80,7 +80,7 @@ class GeneratorTest(TestCase): def test_generate_timestamp(self): timestamp = generate_timestamp() - self.assertIsInstance(timestamp, unicode_type) + self.assertIsInstance(timestamp, str) self.assertTrue(int(timestamp)) self.assertGreater(int(timestamp), 1331672335) @@ -160,11 +160,11 @@ class RequestTest(TestCase): def test_list_body(self): r = Request(URI, body=PARAMS_TWOTUPLE) - self.assertItemsEqual(r.decoded_body, PARAMS_TWOTUPLE) + self.assertCountEqual(r.decoded_body, PARAMS_TWOTUPLE) def test_dict_body(self): r = Request(URI, body=PARAMS_DICT) - self.assertItemsEqual(r.decoded_body, PARAMS_TWOTUPLE) + self.assertCountEqual(r.decoded_body, PARAMS_TWOTUPLE) def test_getattr_existing_attribute(self): r = Request(URI, body='foo bar') diff --git a/tests/unittest/__init__.py b/tests/unittest/__init__.py index 6cb79a6..13ad92f 100644 --- a/tests/unittest/__init__.py +++ b/tests/unittest/__init__.py @@ -1,18 +1,8 @@ -import collections -import sys from unittest import TestCase -try: - import urlparse -except ImportError: - import urllib.parse as urlparse +import urllib.parse as urlparse -# Somewhat consistent itemsequal between all python versions -if sys.version_info[0] == 3: - TestCase.assertItemsEqual = TestCase.assertCountEqual - - -# URL comparison where query param order is insignifcant +# URL comparison where query param order is insignificant def url_equals(self, a, b, parse_fragment=False): parsed_a = urlparse.urlparse(a, allow_fragments=parse_fragment) parsed_b = urlparse.urlparse(b, allow_fragments=parse_fragment) @@ -21,7 +11,7 @@ def url_equals(self, a, b, parse_fragment=False): if parse_fragment: fragment_a = urlparse.parse_qsl(parsed_a.fragment) fragment_b = urlparse.parse_qsl(parsed_b.fragment) - self.assertItemsEqual(fragment_a, fragment_b) + self.assertCountEqual(fragment_a, fragment_b) else: self.assertEqual(parsed_a.fragment, parsed_b.fragment) self.assertEqual(parsed_a.scheme, parsed_b.scheme) @@ -32,10 +22,11 @@ def url_equals(self, a, b, parse_fragment=False): self.assertEqual(parsed_a.password, parsed_b.password) self.assertEqual(parsed_a.hostname, parsed_b.hostname) self.assertEqual(parsed_a.port, parsed_b.port) - self.assertItemsEqual(query_a, query_b) + self.assertCountEqual(query_a, query_b) + TestCase.assertURLEqual = url_equals # Form body comparison where order is insignificant -TestCase.assertFormBodyEqual = lambda self, a, b: self.assertItemsEqual( +TestCase.assertFormBodyEqual = lambda self, a, b: self.assertCountEqual( urlparse.parse_qsl(a), urlparse.parse_qsl(b)) diff --git a/tox.ini b/tox.ini index 4670c91..e2731f3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35,py36,py37,pypy,pypy3,docs,readme,bandit +envlist = py34,py35,py36,py37,pypy,pypy3,docs,readme,bandit [testenv] deps= @@ -29,7 +29,7 @@ commands= twine check dist/* [testenv:bandit] -basepython=python2.7 +basepython=python3.7 skipsdist=True deps=bandit commands=bandit -b bandit.json -r oauthlib/ -- cgit v1.2.1 From 2cec2adf8f54c9eda2a2674f565584aea709ef8a Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 14 Aug 2019 23:44:51 +0300 Subject: Upgrade Python syntax with pyupgrade --- docs/conf.py | 16 ++++++++-------- oauthlib/common.py | 16 ++++++++-------- oauthlib/oauth1/rfc5849/__init__.py | 20 ++++++++++---------- oauthlib/oauth1/rfc5849/endpoints/base.py | 4 ++-- oauthlib/oauth1/rfc5849/endpoints/request_token.py | 2 +- oauthlib/oauth1/rfc5849/errors.py | 4 ++-- oauthlib/oauth1/rfc5849/parameters.py | 2 +- oauthlib/oauth1/rfc5849/request_validator.py | 4 ++-- oauthlib/oauth1/rfc5849/signature.py | 4 ++-- oauthlib/oauth1/rfc5849/utils.py | 2 +- oauthlib/oauth2/rfc6749/clients/base.py | 6 +++--- .../oauth2/rfc6749/clients/legacy_application.py | 2 +- .../oauth2/rfc6749/clients/service_application.py | 2 +- oauthlib/oauth2/rfc6749/clients/web_application.py | 2 +- oauthlib/oauth2/rfc6749/endpoints/base.py | 2 +- oauthlib/oauth2/rfc6749/endpoints/revocation.py | 2 +- oauthlib/oauth2/rfc6749/errors.py | 6 +++--- oauthlib/oauth2/rfc6749/grant_types/base.py | 4 ++-- oauthlib/oauth2/rfc6749/grant_types/refresh_token.py | 4 ++-- oauthlib/oauth2/rfc6749/parameters.py | 4 ++-- oauthlib/oauth2/rfc6749/request_validator.py | 2 +- oauthlib/oauth2/rfc6749/tokens.py | 6 +++--- .../connect/core/grant_types/authorization_code.py | 2 +- oauthlib/openid/connect/core/grant_types/base.py | 4 ++-- .../openid/connect/core/grant_types/dispatchers.py | 2 +- .../openid/connect/core/grant_types/exceptions.py | 2 +- oauthlib/openid/connect/core/grant_types/hybrid.py | 2 +- oauthlib/openid/connect/core/grant_types/implicit.py | 4 ++-- oauthlib/signals.py | 4 ++-- tests/oauth2/rfc6749/clients/test_base.py | 4 ++-- .../rfc6749/clients/test_legacy_application.py | 6 +++--- tests/oauth2/rfc6749/clients/test_web_application.py | 2 +- tests/oauth2/rfc6749/test_parameters.py | 10 +++++----- .../core/grant_types/test_authorization_code.py | 2 +- .../connect/core/grant_types/test_dispatchers.py | 6 +++--- tests/openid/connect/core/grant_types/test_hybrid.py | 8 ++++---- .../openid/connect/core/grant_types/test_implicit.py | 4 ++-- tests/test_common.py | 2 +- 38 files changed, 90 insertions(+), 90 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3388de6..91b5de4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,8 +45,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'OAuthLib' -copyright = u'2019, The OAuthlib Community' +project = 'OAuthLib' +copyright = '2019, The OAuthlib Community' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -190,8 +190,8 @@ latex_elements = { # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'OAuthLib.tex', u'OAuthLib Documentation', - u'The OAuhthlib Community', 'manual'), + ('index', 'OAuthLib.tex', 'OAuthLib Documentation', + 'The OAuhthlib Community', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -220,8 +220,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'oauthlib', u'OAuthLib Documentation', - [u'The OAuthlib Community'], 1) + ('index', 'oauthlib', 'OAuthLib Documentation', + ['The OAuthlib Community'], 1) ] # If true, show URL addresses after external links. @@ -234,8 +234,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'OAuthLib', u'OAuthLib Documentation', - u'The OAuthlib Community', 'OAuthLib', 'One line description of project.', + ('index', 'OAuthLib', 'OAuthLib Documentation', + 'The OAuthlib Community', 'OAuthLib', 'One line description of project.', 'Miscellaneous'), ] diff --git a/oauthlib/common.py b/oauthlib/common.py index 1462e75..52a3567 100644 --- a/oauthlib/common.py +++ b/oauthlib/common.py @@ -300,7 +300,7 @@ def to_unicode(data, encoding='UTF-8'): # We support 2.6 which lacks dict comprehensions if hasattr(data, 'items'): data = data.items() - return dict(((to_unicode(k, encoding), to_unicode(v, encoding)) for k, v in data)) + return {to_unicode(k, encoding): to_unicode(v, encoding) for k, v in data} return data @@ -312,7 +312,7 @@ class CaseInsensitiveDict(dict): proxy = {} def __init__(self, data): - self.proxy = dict((k.lower(), k) for k in data) + self.proxy = {k.lower(): k for k in data} for k in data: self[k] = data[k] @@ -321,27 +321,27 @@ class CaseInsensitiveDict(dict): def __delitem__(self, k): key = self.proxy[k.lower()] - super(CaseInsensitiveDict, self).__delitem__(key) + super().__delitem__(key) del self.proxy[k.lower()] def __getitem__(self, k): key = self.proxy[k.lower()] - return super(CaseInsensitiveDict, self).__getitem__(key) + return super().__getitem__(key) def get(self, k, default=None): return self[k] if k in self else default def __setitem__(self, k, v): - super(CaseInsensitiveDict, self).__setitem__(k, v) + super().__setitem__(k, v) self.proxy[k.lower()] = k def update(self, *args, **kwargs): - super(CaseInsensitiveDict, self).update(*args, **kwargs) + super().update(*args, **kwargs) for k in dict(*args, **kwargs): self.proxy[k.lower()] = k -class Request(object): +class Request: """A malleable representation of a signable HTTP request. @@ -421,7 +421,7 @@ class Request(object): body = SANITIZE_PATTERN.sub('\1', str(body)) if 'Authorization' in headers: headers['Authorization'] = '' - return '' % ( + return ''.format( self.uri, self.http_method, headers, body) @property diff --git a/oauthlib/oauth1/rfc5849/__init__.py b/oauthlib/oauth1/rfc5849/__init__.py index 4f462bb..cdc96e8 100644 --- a/oauthlib/oauth1/rfc5849/__init__.py +++ b/oauthlib/oauth1/rfc5849/__init__.py @@ -36,7 +36,7 @@ SIGNATURE_TYPE_BODY = 'BODY' CONTENT_TYPE_FORM_URLENCODED = 'application/x-www-form-urlencoded' -class Client(object): +class Client: """A client used to sign OAuth 1.0 RFC 5849 requests.""" SIGNATURE_METHODS = { @@ -106,8 +106,8 @@ class Client(object): attrs['rsa_key'] = '****' if attrs['rsa_key'] else None attrs[ 'resource_owner_secret'] = '****' if attrs['resource_owner_secret'] else None - attribute_str = ', '.join('%s=%s' % (k, v) for k, v in attrs.items()) - return '<%s %s>' % (self.__class__.__name__, attribute_str) + attribute_str = ', '.join('{}={}'.format(k, v) for k, v in attrs.items()) + return '<{} {}>'.format(self.__class__.__name__, attribute_str) def get_oauth_signature(self, request): """Get an OAuth signature to be used in signing a request @@ -130,24 +130,24 @@ class Client(object): uri_query=urlparse.urlparse(uri).query, body=body, headers=headers) - log.debug("Collected params: {0}".format(collected_params)) + log.debug("Collected params: {}".format(collected_params)) normalized_params = signature.normalize_parameters(collected_params) normalized_uri = signature.base_string_uri(uri, headers.get('Host', None)) - log.debug("Normalized params: {0}".format(normalized_params)) - log.debug("Normalized URI: {0}".format(normalized_uri)) + log.debug("Normalized params: {}".format(normalized_params)) + log.debug("Normalized URI: {}".format(normalized_uri)) base_string = signature.signature_base_string(request.http_method, normalized_uri, normalized_params) - log.debug("Signing: signature base string: {0}".format(base_string)) + log.debug("Signing: signature base string: {}".format(base_string)) if self.signature_method not in self.SIGNATURE_METHODS: raise ValueError('Invalid signature method.') sig = self.SIGNATURE_METHODS[self.signature_method](base_string, self) - log.debug("Signature: {0}".format(sig)) + log.debug("Signature: {}".format(sig)) return sig def get_oauth_params(self, request): @@ -278,8 +278,8 @@ class Client(object): # header field set to "application/x-www-form-urlencoded". elif not should_have_params and has_params: raise ValueError( - "Body contains parameters but Content-Type header was {0} " - "instead of {1}".format(content_type or "not set", + "Body contains parameters but Content-Type header was {} " + "instead of {}".format(content_type or "not set", CONTENT_TYPE_FORM_URLENCODED)) # 3.5.2. Form-Encoded Body diff --git a/oauthlib/oauth1/rfc5849/endpoints/base.py b/oauthlib/oauth1/rfc5849/endpoints/base.py index f005256..c6428ea 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/base.py +++ b/oauthlib/oauth1/rfc5849/endpoints/base.py @@ -17,7 +17,7 @@ from .. import (CONTENT_TYPE_FORM_URLENCODED, SIGNATURE_HMAC_SHA1, SIGNATURE_HMA SIGNATURE_TYPE_QUERY, errors, signature, utils) -class BaseEndpoint(object): +class BaseEndpoint: def __init__(self, request_validator, token_generator=None): self.request_validator = request_validator @@ -131,7 +131,7 @@ class BaseEndpoint(object): if (not request.signature_method in self.request_validator.allowed_signature_methods): raise errors.InvalidSignatureMethodError( - description="Invalid signature, %s not in %r." % ( + description="Invalid signature, {} not in {!r}.".format( request.signature_method, self.request_validator.allowed_signature_methods)) diff --git a/oauthlib/oauth1/rfc5849/endpoints/request_token.py b/oauthlib/oauth1/rfc5849/endpoints/request_token.py index e9ca331..6749755 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/request_token.py +++ b/oauthlib/oauth1/rfc5849/endpoints/request_token.py @@ -129,7 +129,7 @@ class RequestTokenEndpoint(BaseEndpoint): request.client_key, request) if not self.request_validator.check_realms(request.realms): raise errors.InvalidRequestError( - description='Invalid realm %s. Allowed are %r.' % ( + description='Invalid realm {}. Allowed are {!r}.'.format( request.realms, self.request_validator.realms)) if not request.redirect_uri: diff --git a/oauthlib/oauth1/rfc5849/errors.py b/oauthlib/oauth1/rfc5849/errors.py index a5c59bd..f8c2281 100644 --- a/oauthlib/oauth1/rfc5849/errors.py +++ b/oauthlib/oauth1/rfc5849/errors.py @@ -37,10 +37,10 @@ class OAuth1Error(Exception): request: Oauthlib Request object """ self.description = description or self.description - message = '(%s) %s' % (self.error, self.description) + message = '({}) {}'.format(self.error, self.description) if request: message += ' ' + repr(request) - super(OAuth1Error, self).__init__(message) + super().__init__(message) self.uri = uri self.status_code = status_code diff --git a/oauthlib/oauth1/rfc5849/parameters.py b/oauthlib/oauth1/rfc5849/parameters.py index db4400e..569a136 100644 --- a/oauthlib/oauth1/rfc5849/parameters.py +++ b/oauthlib/oauth1/rfc5849/parameters.py @@ -61,7 +61,7 @@ def prepare_headers(oauth_params, headers=None, realm=None): # 2. Each parameter's name is immediately followed by an "=" character # (ASCII code 61), a """ character (ASCII code 34), the parameter # value (MAY be empty), and another """ character (ASCII code 34). - part = '{0}="{1}"'.format(escaped_name, escaped_value) + part = '{}="{}"'.format(escaped_name, escaped_value) authorization_header_parameters_parts.append(part) diff --git a/oauthlib/oauth1/rfc5849/request_validator.py b/oauthlib/oauth1/rfc5849/request_validator.py index 330bcbb..db5f1dd 100644 --- a/oauthlib/oauth1/rfc5849/request_validator.py +++ b/oauthlib/oauth1/rfc5849/request_validator.py @@ -13,7 +13,7 @@ import sys from . import SIGNATURE_METHODS, utils -class RequestValidator(object): +class RequestValidator: """A validator/datastore interaction base class for OAuth 1 providers. @@ -197,7 +197,7 @@ class RequestValidator(object): def check_realms(self, realms): """Check that the realm is one of a set allowed realms.""" - return all((r in self.realms for r in realms)) + return all(r in self.realms for r in realms) def _subclass_must_implement(self, fn): """ diff --git a/oauthlib/oauth1/rfc5849/signature.py b/oauthlib/oauth1/rfc5849/signature.py index 5b080aa..78de755 100644 --- a/oauthlib/oauth1/rfc5849/signature.py +++ b/oauthlib/oauth1/rfc5849/signature.py @@ -300,7 +300,7 @@ def collect_parameters(uri_query='', body=[], headers=None, # # .. _`Section 3.5.1`: https://tools.ietf.org/html/rfc5849#section-3.5.1 if headers: - headers_lower = dict((k.lower(), v) for k, v in headers.items()) + headers_lower = {k.lower(): v for k, v in headers.items()} authorization_header = headers_lower.get('authorization') if authorization_header is not None: params.extend([i for i in utils.parse_authorization_header( @@ -429,7 +429,7 @@ def normalize_parameters(params): # 3. The name of each parameter is concatenated to its corresponding # value using an "=" character (ASCII code 61) as a separator, even # if the value is empty. - parameter_parts = ['{0}={1}'.format(k, v) for k, v in key_values] + parameter_parts = ['{}={}'.format(k, v) for k, v in key_values] # 4. The sorted name/value pairs are concatenated together into a # single string by using an "&" character (ASCII code 38) as diff --git a/oauthlib/oauth1/rfc5849/utils.py b/oauthlib/oauth1/rfc5849/utils.py index a010aea..83df65c 100644 --- a/oauthlib/oauth1/rfc5849/utils.py +++ b/oauthlib/oauth1/rfc5849/utils.py @@ -54,7 +54,7 @@ def escape(u): """ if not isinstance(u, str): raise ValueError('Only unicode objects are escapable. ' + - 'Got %r of type %s.' % (u, type(u))) + 'Got {!r} of type {}.'.format(u, type(u))) # Letters, digits, and the characters '_.-' are already treated as safe # by urllib.quote(). We need to add '~' to fully support rfc5849. return quote(u, safe=b'~') diff --git a/oauthlib/oauth2/rfc6749/clients/base.py b/oauthlib/oauth2/rfc6749/clients/base.py index 9b05ad5..c028552 100644 --- a/oauthlib/oauth2/rfc6749/clients/base.py +++ b/oauthlib/oauth2/rfc6749/clients/base.py @@ -29,7 +29,7 @@ FORM_ENC_HEADERS = { } -class Client(object): +class Client: """Base OAuth2 client responsible for access token management. This class also acts as a generic interface providing methods common to all @@ -186,8 +186,8 @@ class Client(object): token_placement = token_placement or self.default_token_placement - case_insensitive_token_types = dict( - (k.lower(), v) for k, v in self.token_types.items()) + case_insensitive_token_types = { + k.lower(): v for k, v in self.token_types.items()} if not self.token_type.lower() in case_insensitive_token_types: raise ValueError("Unsupported token type: %s" % self.token_type) diff --git a/oauthlib/oauth2/rfc6749/clients/legacy_application.py b/oauthlib/oauth2/rfc6749/clients/legacy_application.py index ca218e4..c224c33 100644 --- a/oauthlib/oauth2/rfc6749/clients/legacy_application.py +++ b/oauthlib/oauth2/rfc6749/clients/legacy_application.py @@ -38,7 +38,7 @@ class LegacyApplicationClient(Client): grant_type = 'password' def __init__(self, client_id, **kwargs): - super(LegacyApplicationClient, self).__init__(client_id, **kwargs) + super().__init__(client_id, **kwargs) def prepare_request_body(self, username, password, body='', scope=None, include_client_id=False, **kwargs): diff --git a/oauthlib/oauth2/rfc6749/clients/service_application.py b/oauthlib/oauth2/rfc6749/clients/service_application.py index ea946ce..00ea018 100644 --- a/oauthlib/oauth2/rfc6749/clients/service_application.py +++ b/oauthlib/oauth2/rfc6749/clients/service_application.py @@ -57,7 +57,7 @@ class ServiceApplicationClient(Client): state and token. See ``Client.__init__.__doc__`` for details. """ - super(ServiceApplicationClient, self).__init__(client_id, **kwargs) + super().__init__(client_id, **kwargs) self.private_key = private_key self.subject = subject self.issuer = issuer diff --git a/oauthlib/oauth2/rfc6749/clients/web_application.py b/oauthlib/oauth2/rfc6749/clients/web_application.py index 0cd39ce..fe64ef0 100644 --- a/oauthlib/oauth2/rfc6749/clients/web_application.py +++ b/oauthlib/oauth2/rfc6749/clients/web_application.py @@ -38,7 +38,7 @@ class WebApplicationClient(Client): grant_type = 'authorization_code' def __init__(self, client_id, code=None, **kwargs): - super(WebApplicationClient, self).__init__(client_id, **kwargs) + super().__init__(client_id, **kwargs) self.code = code def prepare_request_uri(self, uri, redirect_uri=None, scope=None, diff --git a/oauthlib/oauth2/rfc6749/endpoints/base.py b/oauthlib/oauth2/rfc6749/endpoints/base.py index e39232f..e69ccf0 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/base.py +++ b/oauthlib/oauth2/rfc6749/endpoints/base.py @@ -20,7 +20,7 @@ from oauthlib.common import CaseInsensitiveDict, urldecode log = logging.getLogger(__name__) -class BaseEndpoint(object): +class BaseEndpoint: def __init__(self): self._available = True diff --git a/oauthlib/oauth2/rfc6749/endpoints/revocation.py b/oauthlib/oauth2/rfc6749/endpoints/revocation.py index 1fabd03..cda6375 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/revocation.py +++ b/oauthlib/oauth2/rfc6749/endpoints/revocation.py @@ -73,7 +73,7 @@ class RevocationEndpoint(BaseEndpoint): log.debug('Client error during validation of %r. %r.', request, e) response_body = e.json if self.enable_jsonp and request.callback: - response_body = '%s(%s);' % (request.callback, response_body) + response_body = '{}({});'.format(request.callback, response_body) resp_headers.update(e.headers) return resp_headers, response_body, e.status_code diff --git a/oauthlib/oauth2/rfc6749/errors.py b/oauthlib/oauth2/rfc6749/errors.py index d2a1402..8f88bb4 100644 --- a/oauthlib/oauth2/rfc6749/errors.py +++ b/oauthlib/oauth2/rfc6749/errors.py @@ -45,10 +45,10 @@ class OAuth2Error(Exception): if description is not None: self.description = description - message = '(%s) %s' % (self.error, self.description) + message = '({}) {}'.format(self.error, self.description) if request: message += ' ' + repr(request) - super(OAuth2Error, self).__init__(message) + super().__init__(message) self.uri = uri self.state = state @@ -389,7 +389,7 @@ class CustomOAuth2Error(OAuth2Error): """ def __init__(self, error, *args, **kwargs): self.error = error - super(CustomOAuth2Error, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def raise_from_error(error, params=None): diff --git a/oauthlib/oauth2/rfc6749/grant_types/base.py b/oauthlib/oauth2/rfc6749/grant_types/base.py index f0772e2..b4c3665 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/base.py +++ b/oauthlib/oauth2/rfc6749/grant_types/base.py @@ -17,7 +17,7 @@ from ..request_validator import RequestValidator log = logging.getLogger(__name__) -class ValidatorsContainer(object): +class ValidatorsContainer: """ Container object for holding custom validator callables to be invoked as part of the grant type `validate_authorization_request()` or @@ -74,7 +74,7 @@ class ValidatorsContainer(object): return chain(self.post_auth, self.post_token) -class GrantTypeBase(object): +class GrantTypeBase: error_uri = None request_validator = None default_response_mode = 'fragment' diff --git a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py index fc61d65..5f0db28 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py +++ b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py @@ -25,7 +25,7 @@ class RefreshTokenGrant(GrantTypeBase): def __init__(self, request_validator=None, issue_new_refresh_tokens=True, **kwargs): - super(RefreshTokenGrant, self).__init__( + super().__init__( request_validator, issue_new_refresh_tokens=issue_new_refresh_tokens, **kwargs) @@ -126,7 +126,7 @@ class RefreshTokenGrant(GrantTypeBase): if request.scope: request.scopes = utils.scope_to_list(request.scope) - if (not all((s in original_scopes for s in request.scopes)) + if (not all(s in original_scopes for s in request.scopes) and not self.request_validator.is_within_original_scope( request.scopes, request.refresh_token, request)): log.debug('Refresh token %s lack requested scopes, %r.', diff --git a/oauthlib/oauth2/rfc6749/parameters.py b/oauthlib/oauth2/rfc6749/parameters.py index b6249d8..a3f9dd0 100644 --- a/oauthlib/oauth2/rfc6749/parameters.py +++ b/oauthlib/oauth2/rfc6749/parameters.py @@ -146,13 +146,13 @@ def prepare_token_request(grant_type, body='', include_client_id=True, **kwargs) client_id = kwargs.pop('client_id', None) if include_client_id: if client_id is not None: - params.append((str('client_id'), client_id)) + params.append(('client_id', client_id)) # the kwargs iteration below only supports including boolean truth (truthy) # values, but some servers may require an empty string for `client_secret` client_secret = kwargs.pop('client_secret', None) if client_secret is not None: - params.append((str('client_secret'), client_secret)) + params.append(('client_secret', client_secret)) # this handles: `code`, `redirect_uri`, and other undocumented params for k in kwargs: diff --git a/oauthlib/oauth2/rfc6749/request_validator.py b/oauthlib/oauth2/rfc6749/request_validator.py index 86509b6..eeef50e 100644 --- a/oauthlib/oauth2/rfc6749/request_validator.py +++ b/oauthlib/oauth2/rfc6749/request_validator.py @@ -10,7 +10,7 @@ import logging log = logging.getLogger(__name__) -class RequestValidator(object): +class RequestValidator: def client_authentication_required(self, request, *args, **kwargs): """Determine if client authentication is required for current request. diff --git a/oauthlib/oauth2/rfc6749/tokens.py b/oauthlib/oauth2/rfc6749/tokens.py index 5b99f0c..8873ed5 100644 --- a/oauthlib/oauth2/rfc6749/tokens.py +++ b/oauthlib/oauth2/rfc6749/tokens.py @@ -28,7 +28,7 @@ except ImportError: class OAuth2Token(dict): def __init__(self, params, old_scope=None): - super(OAuth2Token, self).__init__(params) + super().__init__(params) self._new_scope = None if 'scope' in params and params['scope']: self._new_scope = set(utils.scope_to_list(params['scope'])) @@ -121,7 +121,7 @@ def prepare_mac_header(token, uri, key, http_method, raise ValueError('unknown hash algorithm') if draft == 0: - nonce = nonce or '{0}:{1}'.format(utils.generate_age(issue_time), + nonce = nonce or '{}:{}'.format(utils.generate_age(issue_time), common.generate_nonce()) else: ts = common.generate_timestamp() @@ -262,7 +262,7 @@ def get_token_from_header(request): return token -class TokenBase(object): +class TokenBase: def __call__(self, request, refresh_token=False): raise NotImplementedError('Subclasses must implement this method.') diff --git a/oauthlib/openid/connect/core/grant_types/authorization_code.py b/oauthlib/openid/connect/core/grant_types/authorization_code.py index becfcfa..7047e1e 100644 --- a/oauthlib/openid/connect/core/grant_types/authorization_code.py +++ b/oauthlib/openid/connect/core/grant_types/authorization_code.py @@ -41,4 +41,4 @@ class AuthorizationCodeGrant(GrantTypeBase): request.redirect_uri, request ) - return super(AuthorizationCodeGrant, self).add_id_token(token, token_handler, request, nonce=nonce) + return super().add_id_token(token, token_handler, request, nonce=nonce) diff --git a/oauthlib/openid/connect/core/grant_types/base.py b/oauthlib/openid/connect/core/grant_types/base.py index 32a21b6..cd27237 100644 --- a/oauthlib/openid/connect/core/grant_types/base.py +++ b/oauthlib/openid/connect/core/grant_types/base.py @@ -11,7 +11,7 @@ from oauthlib.oauth2.rfc6749.errors import ConsentRequired, InvalidRequestError, log = logging.getLogger(__name__) -class GrantTypeBase(object): +class GrantTypeBase: # Just proxy the majority of method calls through to the # proxy_target grant type handler, which will usually be either @@ -20,7 +20,7 @@ class GrantTypeBase(object): return getattr(self.proxy_target, attr) def __setattr__(self, attr, value): - proxied_attrs = set(('refresh_token', 'response_types')) + proxied_attrs = {'refresh_token', 'response_types'} if attr in proxied_attrs: setattr(self.proxy_target, attr, value) else: diff --git a/oauthlib/openid/connect/core/grant_types/dispatchers.py b/oauthlib/openid/connect/core/grant_types/dispatchers.py index be8e2f3..541467a 100644 --- a/oauthlib/openid/connect/core/grant_types/dispatchers.py +++ b/oauthlib/openid/connect/core/grant_types/dispatchers.py @@ -2,7 +2,7 @@ import logging log = logging.getLogger(__name__) -class Dispatcher(object): +class Dispatcher: default_grant = None oidc_grant = None diff --git a/oauthlib/openid/connect/core/grant_types/exceptions.py b/oauthlib/openid/connect/core/grant_types/exceptions.py index 809f1b3..4636fe7 100644 --- a/oauthlib/openid/connect/core/grant_types/exceptions.py +++ b/oauthlib/openid/connect/core/grant_types/exceptions.py @@ -29,4 +29,4 @@ class OIDCNoPrompt(Exception): "for authorization, it should been done using silent " "authentication through create_authorization_response. " "See OIDCNoPrompt.__doc__ for more details.") - super(OIDCNoPrompt, self).__init__(msg) + super().__init__(msg) diff --git a/oauthlib/openid/connect/core/grant_types/hybrid.py b/oauthlib/openid/connect/core/grant_types/hybrid.py index 685fa08..af86d10 100644 --- a/oauthlib/openid/connect/core/grant_types/hybrid.py +++ b/oauthlib/openid/connect/core/grant_types/hybrid.py @@ -39,7 +39,7 @@ class HybridGrant(GrantTypeBase): def openid_authorization_validator(self, request): """Additional validation when following the Authorization Code flow. """ - request_info = super(HybridGrant, self).openid_authorization_validator(request) + request_info = super().openid_authorization_validator(request) if not request_info: # returns immediately if OAuth2.0 return request_info diff --git a/oauthlib/openid/connect/core/grant_types/implicit.py b/oauthlib/openid/connect/core/grant_types/implicit.py index c2dbc27..aefec57 100644 --- a/oauthlib/openid/connect/core/grant_types/implicit.py +++ b/oauthlib/openid/connect/core/grant_types/implicit.py @@ -29,12 +29,12 @@ class ImplicitGrant(GrantTypeBase): def add_id_token(self, token, token_handler, request): if 'state' not in token and request.state: token['state'] = request.state - return super(ImplicitGrant, self).add_id_token(token, token_handler, request, nonce=request.nonce) + return super().add_id_token(token, token_handler, request, nonce=request.nonce) def openid_authorization_validator(self, request): """Additional validation when following the implicit flow. """ - request_info = super(ImplicitGrant, self).openid_authorization_validator(request) + request_info = super().openid_authorization_validator(request) if not request_info: # returns immediately if OAuth2.0 return request_info diff --git a/oauthlib/signals.py b/oauthlib/signals.py index 22d47a4..9356cc2 100644 --- a/oauthlib/signals.py +++ b/oauthlib/signals.py @@ -9,11 +9,11 @@ try: from blinker import Namespace signals_available = True except ImportError: # noqa - class Namespace(object): + class Namespace: def signal(self, name, doc=None): return _FakeSignal(name, doc) - class _FakeSignal(object): + class _FakeSignal: """If blinker is unavailable, create a fake class with the same interface that allows sending of signals but will fail with an error on anything else. Instead of doing anything on send, it diff --git a/tests/oauth2/rfc6749/clients/test_base.py b/tests/oauth2/rfc6749/clients/test_base.py index d48a944..4fbada9 100644 --- a/tests/oauth2/rfc6749/clients/test_base.py +++ b/tests/oauth2/rfc6749/clients/test_base.py @@ -295,11 +295,11 @@ class ClientTest(TestCase): u, h, b = client.prepare_refresh_token_request(url, token, scope=scope) self.assertEqual(u, url) self.assertEqual(h, {'Content-Type': 'application/x-www-form-urlencoded'}) - self.assertFormBodyEqual(b, 'grant_type=refresh_token&scope=%s&refresh_token=%s' % (scope, token)) + self.assertFormBodyEqual(b, 'grant_type=refresh_token&scope={}&refresh_token={}'.format(scope, token)) # provide scope while init client = Client(self.client_id, scope=scope) u, h, b = client.prepare_refresh_token_request(url, token, scope=scope) self.assertEqual(u, url) self.assertEqual(h, {'Content-Type': 'application/x-www-form-urlencoded'}) - self.assertFormBodyEqual(b, 'grant_type=refresh_token&scope=%s&refresh_token=%s' % (scope, token)) + self.assertFormBodyEqual(b, 'grant_type=refresh_token&scope={}&refresh_token={}'.format(scope, token)) diff --git a/tests/oauth2/rfc6749/clients/test_legacy_application.py b/tests/oauth2/rfc6749/clients/test_legacy_application.py index 21af4a3..01e46e4 100644 --- a/tests/oauth2/rfc6749/clients/test_legacy_application.py +++ b/tests/oauth2/rfc6749/clients/test_legacy_application.py @@ -32,7 +32,7 @@ class LegacyApplicationClientTest(TestCase): password = "user_password" body = "not=empty" - body_up = "not=empty&grant_type=password&username=%s&password=%s" % (username, password) + body_up = "not=empty&grant_type=password&username={}&password={}".format(username, password) body_kwargs = body_up + "&some=providers&require=extra+arguments" token_json = ('{ "access_token":"2YotnFZFEjr1zCsicMWpAA",' @@ -105,8 +105,8 @@ class LegacyApplicationClientTest(TestCase): # scenario 1, default behavior to not include `client_id` r1 = client.prepare_request_body(username=self.username, password=self.password) - self.assertIn(r1, ('grant_type=password&username=%s&password=%s' % (self.username, self.password, ), - 'grant_type=password&password=%s&username=%s' % (self.password, self.username, ), + self.assertIn(r1, ('grant_type=password&username={}&password={}'.format(self.username, self.password), + 'grant_type=password&password={}&username={}'.format(self.password, self.username), )) # scenario 2, include `client_id` in the body diff --git a/tests/oauth2/rfc6749/clients/test_web_application.py b/tests/oauth2/rfc6749/clients/test_web_application.py index 092f93e..f7fbb02 100644 --- a/tests/oauth2/rfc6749/clients/test_web_application.py +++ b/tests/oauth2/rfc6749/clients/test_web_application.py @@ -46,7 +46,7 @@ class WebApplicationClientTest(TestCase): code = "zzzzaaaa" body = "not=empty" - body_code = "not=empty&grant_type=authorization_code&code=%s&client_id=%s" % (code, client_id) + body_code = "not=empty&grant_type=authorization_code&code={}&client_id={}".format(code, client_id) body_redirect = body_code + "&redirect_uri=http%3A%2F%2Fmy.page.com%2Fcallback" body_kwargs = body_code + "&some=providers&require=extra+arguments" diff --git a/tests/oauth2/rfc6749/test_parameters.py b/tests/oauth2/rfc6749/test_parameters.py index 48b7eac..5e449f4 100644 --- a/tests/oauth2/rfc6749/test_parameters.py +++ b/tests/oauth2/rfc6749/test_parameters.py @@ -77,9 +77,9 @@ class ParameterTests(TestCase): error_invalid = 'https://client.example.com/cb?error=invalid_request&state=xyz' implicit_base = 'https://example.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA&scope=abc&' - implicit_response = implicit_base + 'state={0}&token_type=example&expires_in=3600'.format(state) - implicit_notype = implicit_base + 'state={0}&expires_in=3600'.format(state) - implicit_wrongstate = implicit_base + 'state={0}&token_type=exampleexpires_in=3600'.format('invalid') + implicit_response = implicit_base + 'state={}&token_type=example&expires_in=3600'.format(state) + implicit_notype = implicit_base + 'state={}&expires_in=3600'.format(state) + implicit_wrongstate = implicit_base + 'state={}&token_type=exampleexpires_in=3600'.format('invalid') implicit_nostate = implicit_base + 'token_type=example&expires_in=3600' implicit_notoken = 'https://example.com/cb#state=xyz&token_type=example&expires_in=3600' @@ -244,7 +244,7 @@ class ParameterTests(TestCase): for scope in new + old: self.assertIn(scope, message) self.assertEqual(old, ['aaa']) - self.assertEqual(set(new), set(['abc', 'def'])) + self.assertEqual(set(new), {'abc', 'def'}) finally: signals.scope_changed.disconnect(record_scope_change) del os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] @@ -278,7 +278,7 @@ class ParameterTests(TestCase): for scope in new + old: self.assertIn(scope, message) self.assertEqual(old, ['aaa']) - self.assertEqual(set(new), set(['abc', 'def'])) + self.assertEqual(set(new), {'abc', 'def'}) finally: signals.scope_changed.disconnect(record_scope_change) del os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] diff --git a/tests/openid/connect/core/grant_types/test_authorization_code.py b/tests/openid/connect/core/grant_types/test_authorization_code.py index b721a19..76a4e97 100644 --- a/tests/openid/connect/core/grant_types/test_authorization_code.py +++ b/tests/openid/connect/core/grant_types/test_authorization_code.py @@ -24,7 +24,7 @@ class OpenIDAuthCodeInterferenceTest(AuthorizationCodeGrantTest): """Test that OpenID don't interfere with normal OAuth 2 flows.""" def setUp(self): - super(OpenIDAuthCodeInterferenceTest, self).setUp() + super().setUp() self.auth = AuthorizationCodeGrant(request_validator=self.mock_validator) diff --git a/tests/openid/connect/core/grant_types/test_dispatchers.py b/tests/openid/connect/core/grant_types/test_dispatchers.py index 9e45d65..53625b2 100644 --- a/tests/openid/connect/core/grant_types/test_dispatchers.py +++ b/tests/openid/connect/core/grant_types/test_dispatchers.py @@ -72,7 +72,7 @@ class DispatcherTest(TestCase): class AuthTokenGrantDispatcherOpenIdTest(DispatcherTest): def setUp(self): - super(AuthTokenGrantDispatcherOpenIdTest, self).setUp() + super().setUp() self.request_validator.get_authorization_code_scopes.return_value = ('hello', 'openid') self.dispatcher = AuthorizationTokenGrantDispatcher( self.request_validator, @@ -89,7 +89,7 @@ class AuthTokenGrantDispatcherOpenIdTest(DispatcherTest): class AuthTokenGrantDispatcherOpenIdWithoutCodeTest(DispatcherTest): def setUp(self): - super(AuthTokenGrantDispatcherOpenIdWithoutCodeTest, self).setUp() + super().setUp() self.request.decoded_body = ( ("client_id", "me"), ("code", ""), @@ -111,7 +111,7 @@ class AuthTokenGrantDispatcherOpenIdWithoutCodeTest(DispatcherTest): class AuthTokenGrantDispatcherOAuthTest(DispatcherTest): def setUp(self): - super(AuthTokenGrantDispatcherOAuthTest, self).setUp() + super().setUp() self.request_validator.get_authorization_code_scopes.return_value = ('hello', 'world') self.dispatcher = AuthorizationTokenGrantDispatcher( self.request_validator, diff --git a/tests/openid/connect/core/grant_types/test_hybrid.py b/tests/openid/connect/core/grant_types/test_hybrid.py index 0aa0add..08dcc13 100644 --- a/tests/openid/connect/core/grant_types/test_hybrid.py +++ b/tests/openid/connect/core/grant_types/test_hybrid.py @@ -15,14 +15,14 @@ class OpenIDHybridInterferenceTest(AuthorizationCodeGrantTest): """Test that OpenID don't interfere with normal OAuth 2 flows.""" def setUp(self): - super(OpenIDHybridInterferenceTest, self).setUp() + super().setUp() self.auth = HybridGrant(request_validator=self.mock_validator) class OpenIDHybridCodeTokenTest(OpenIDAuthCodeTest): def setUp(self): - super(OpenIDHybridCodeTokenTest, self).setUp() + super().setUp() self.request.response_type = 'code token' self.request.nonce = None self.auth = HybridGrant(request_validator=self.mock_validator) @@ -45,7 +45,7 @@ class OpenIDHybridCodeTokenTest(OpenIDAuthCodeTest): class OpenIDHybridCodeIdTokenTest(OpenIDAuthCodeTest): def setUp(self): - super(OpenIDHybridCodeIdTokenTest, self).setUp() + super().setUp() self.mock_validator.get_code_challenge.return_value = None self.request.response_type = 'code id_token' self.request.nonce = 'zxc' @@ -70,7 +70,7 @@ class OpenIDHybridCodeIdTokenTest(OpenIDAuthCodeTest): class OpenIDHybridCodeIdTokenTokenTest(OpenIDAuthCodeTest): def setUp(self): - super(OpenIDHybridCodeIdTokenTokenTest, self).setUp() + super().setUp() self.mock_validator.get_code_challenge.return_value = None self.request.response_type = 'code id_token token' self.request.nonce = 'xyz' diff --git a/tests/openid/connect/core/grant_types/test_implicit.py b/tests/openid/connect/core/grant_types/test_implicit.py index 1ee805c..e94ad30 100644 --- a/tests/openid/connect/core/grant_types/test_implicit.py +++ b/tests/openid/connect/core/grant_types/test_implicit.py @@ -17,7 +17,7 @@ class OpenIDImplicitInterferenceTest(ImplicitGrantTest): """Test that OpenID don't interfere with normal OAuth 2 flows.""" def setUp(self): - super(OpenIDImplicitInterferenceTest, self).setUp() + super().setUp() self.auth = ImplicitGrant(request_validator=self.mock_validator) @@ -114,7 +114,7 @@ class OpenIDImplicitTest(TestCase): class OpenIDImplicitNoAccessTokenTest(OpenIDImplicitTest): def setUp(self): - super(OpenIDImplicitNoAccessTokenTest, self).setUp() + super().setUp() self.request.response_type = 'id_token' token = 'MOCKED_TOKEN' self.url_query = 'https://a.b/cb?state=abc&id_token=%s' % token diff --git a/tests/test_common.py b/tests/test_common.py index c2c5e41..2a9a264 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -71,7 +71,7 @@ class ParameterTest(TestCase): self.assertEqual(extract_params([('')]), None) def test_add_params_to_uri(self): - correct = '%s?%s' % (URI, PARAMS_FORMENCODED) + correct = '{}?{}'.format(URI, PARAMS_FORMENCODED) self.assertURLEqual(add_params_to_uri(URI, PARAMS_DICT), correct) self.assertURLEqual(add_params_to_uri(URI, PARAMS_TWOTUPLE), correct) -- cgit v1.2.1 From 81e37c08162124854822581e23ac2cd81fa43d4a Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 14 Aug 2019 23:45:58 +0300 Subject: Drop the dot https://twitter.com/pytestdotorg/status/753767547866972160 --- docs/contributing.rst | 4 ++-- tox.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index 93f6a81..8244afd 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -144,7 +144,7 @@ the project root via: .. sourcecode:: bash - $ py.test + $ pytest The first thing the core committers will do is run this command. Any pull request that fails this test suite will be **rejected**. @@ -299,7 +299,7 @@ First we pull the code into a local branch:: Then we run the tests:: - py.test + pytest We finish with a non-fastforward merge (to preserve the branch history) and push to GitHub:: diff --git a/tox.ini b/tox.ini index e2731f3..1e325ae 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ envlist = py34,py35,py36,py37,pypy,pypy3,docs,readme,bandit deps= -rrequirements-test.txt commands= - py.test --cov=oauthlib tests/ + pytest --cov=oauthlib tests/ # tox -e docs to mimick readthedocs build. -- cgit v1.2.1 From b41d4801dec588d82e6633869ac541e207598297 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 15 Aug 2019 00:01:16 +0300 Subject: Drop support for legacy Python 2.7 --- oauthlib/common.py | 17 ++++------------- oauthlib/oauth1/rfc5849/__init__.py | 6 +----- oauthlib/oauth1/rfc5849/endpoints/authorization.py | 6 +----- oauthlib/oauth1/rfc5849/parameters.py | 5 +---- oauthlib/oauth1/rfc5849/signature.py | 5 +---- oauthlib/oauth1/rfc5849/utils.py | 5 +---- oauthlib/oauth2/rfc6749/parameters.py | 6 +----- oauthlib/oauth2/rfc6749/tokens.py | 5 +---- oauthlib/oauth2/rfc6749/utils.py | 11 ++--------- setup.py | 1 - tests/oauth1/rfc5849/test_signatures.py | 5 +---- tests/oauth2/rfc6749/clients/test_legacy_application.py | 6 +----- tests/oauth2/rfc6749/clients/test_web_application.py | 6 +----- tests/oauth2/rfc6749/endpoints/test_utils.py | 5 +---- .../endpoints/test_openid_connect_params_handling.py | 6 +----- 15 files changed, 18 insertions(+), 77 deletions(-) diff --git a/oauthlib/common.py b/oauthlib/common.py index 52a3567..f4571ca 100644 --- a/oauthlib/common.py +++ b/oauthlib/common.py @@ -12,9 +12,12 @@ import collections import datetime import logging import re -import sys import time +import urllib.parse as urlparse from . import get_debug +from urllib.parse import quote as _quote +from urllib.parse import unquote as _unquote +from urllib.parse import urlencode as _urlencode try: from secrets import randbits @@ -22,18 +25,6 @@ try: except ImportError: from random import getrandbits as randbits from random import SystemRandom -try: - from urllib import quote as _quote - from urllib import unquote as _unquote - from urllib import urlencode as _urlencode -except ImportError: - from urllib.parse import quote as _quote - from urllib.parse import unquote as _unquote - from urllib.parse import urlencode as _urlencode -try: - import urlparse -except ImportError: - import urllib.parse as urlparse UNICODE_ASCII_CHARACTER_SET = ('abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' diff --git a/oauthlib/oauth1/rfc5849/__init__.py b/oauthlib/oauth1/rfc5849/__init__.py index cdc96e8..da9b1ac 100644 --- a/oauthlib/oauth1/rfc5849/__init__.py +++ b/oauthlib/oauth1/rfc5849/__init__.py @@ -12,11 +12,7 @@ import hashlib import logging log = logging.getLogger(__name__) -import sys -try: - import urlparse -except ImportError: - import urllib.parse as urlparse +import urllib.parse as urlparse from oauthlib.common import Request, urlencode, generate_nonce from oauthlib.common import generate_timestamp, to_unicode diff --git a/oauthlib/oauth1/rfc5849/endpoints/authorization.py b/oauthlib/oauth1/rfc5849/endpoints/authorization.py index b465946..945da74 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/authorization.py +++ b/oauthlib/oauth1/rfc5849/endpoints/authorization.py @@ -12,11 +12,7 @@ from oauthlib.common import Request, add_params_to_uri from .. import errors from .base import BaseEndpoint - -try: - from urllib import urlencode -except ImportError: - from urllib.parse import urlencode +from urllib.parse import urlencode class AuthorizationEndpoint(BaseEndpoint): diff --git a/oauthlib/oauth1/rfc5849/parameters.py b/oauthlib/oauth1/rfc5849/parameters.py index 569a136..95e07d5 100644 --- a/oauthlib/oauth1/rfc5849/parameters.py +++ b/oauthlib/oauth1/rfc5849/parameters.py @@ -13,10 +13,7 @@ from oauthlib.common import extract_params, urlencode from . import utils -try: - from urlparse import urlparse, urlunparse -except ImportError: # noqa - from urllib.parse import urlparse, urlunparse +from urllib.parse import urlparse, urlunparse # TODO: do we need filter_params now that oauth_params are handled by Request? diff --git a/oauthlib/oauth1/rfc5849/signature.py b/oauthlib/oauth1/rfc5849/signature.py index 78de755..ea6ab39 100644 --- a/oauthlib/oauth1/rfc5849/signature.py +++ b/oauthlib/oauth1/rfc5849/signature.py @@ -29,13 +29,10 @@ import hmac import logging from oauthlib.common import extract_params, safe_string_equals, urldecode +import urllib.parse as urlparse from . import utils -try: - import urlparse -except ImportError: - import urllib.parse as urlparse log = logging.getLogger(__name__) diff --git a/oauthlib/oauth1/rfc5849/utils.py b/oauthlib/oauth1/rfc5849/utils.py index 83df65c..2dfc1f7 100644 --- a/oauthlib/oauth1/rfc5849/utils.py +++ b/oauthlib/oauth1/rfc5849/utils.py @@ -10,10 +10,7 @@ from __future__ import absolute_import, unicode_literals from oauthlib.common import quote, unquote -try: - import urllib2 -except ImportError: - import urllib.request as urllib2 +import urllib.request as urllib2 UNICODE_ASCII_CHARACTER_SET = ('abcdefghijklmnopqrstuvwxyz' diff --git a/oauthlib/oauth2/rfc6749/parameters.py b/oauthlib/oauth2/rfc6749/parameters.py index a3f9dd0..2bca4d2 100644 --- a/oauthlib/oauth2/rfc6749/parameters.py +++ b/oauthlib/oauth2/rfc6749/parameters.py @@ -15,6 +15,7 @@ import time from oauthlib.common import add_params_to_qs, add_params_to_uri from oauthlib.signals import scope_changed +import urllib.parse as urlparse from .errors import (InsecureTransportError, MismatchingStateError, MissingCodeError, MissingTokenError, @@ -22,11 +23,6 @@ from .errors import (InsecureTransportError, MismatchingStateError, from .tokens import OAuth2Token from .utils import is_secure_transport, list_to_scope, scope_to_list -try: - import urlparse -except ImportError: - import urllib.parse as urlparse - def prepare_grant_uri(uri, client_id, response_type, redirect_uri=None, scope=None, state=None, **kwargs): diff --git a/oauthlib/oauth2/rfc6749/tokens.py b/oauthlib/oauth2/rfc6749/tokens.py index 8873ed5..8e139f6 100644 --- a/oauthlib/oauth2/rfc6749/tokens.py +++ b/oauthlib/oauth2/rfc6749/tokens.py @@ -16,13 +16,10 @@ import warnings from oauthlib import common from oauthlib.common import add_params_to_qs, add_params_to_uri +from urllib.parse import urlparse from . import utils -try: - from urlparse import urlparse -except ImportError: - from urllib.parse import urlparse class OAuth2Token(dict): diff --git a/oauthlib/oauth2/rfc6749/utils.py b/oauthlib/oauth2/rfc6749/utils.py index 7516c9e..efbf8aa 100644 --- a/oauthlib/oauth2/rfc6749/utils.py +++ b/oauthlib/oauth2/rfc6749/utils.py @@ -11,15 +11,8 @@ import datetime import os from oauthlib.common import urldecode - -try: - from urllib import quote -except ImportError: - from urllib.parse import quote -try: - from urlparse import urlparse -except ImportError: - from urllib.parse import urlparse +from urllib.parse import quote +from urllib.parse import urlparse def list_to_scope(scope): diff --git a/setup.py b/setup.py index 0aebd6c..438b8ae 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,6 @@ try: except ImportError: pass -import sys from os.path import dirname, join from setuptools import find_packages, setup diff --git a/tests/oauth1/rfc5849/test_signatures.py b/tests/oauth1/rfc5849/test_signatures.py index 4eb7ff3..48a17c4 100644 --- a/tests/oauth1/rfc5849/test_signatures.py +++ b/tests/oauth1/rfc5849/test_signatures.py @@ -11,13 +11,10 @@ from oauthlib.oauth1.rfc5849.signature import (collect_parameters, sign_plaintext_with_client, sign_rsa_sha1, sign_rsa_sha1_with_client) +from urllib.parse import quote from ...unittest import TestCase -try: - from urllib import quote -except ImportError: - from urllib.parse import quote diff --git a/tests/oauth2/rfc6749/clients/test_legacy_application.py b/tests/oauth2/rfc6749/clients/test_legacy_application.py index 01e46e4..20fb24b 100644 --- a/tests/oauth2/rfc6749/clients/test_legacy_application.py +++ b/tests/oauth2/rfc6749/clients/test_legacy_application.py @@ -7,14 +7,10 @@ from mock import patch from oauthlib import signals from oauthlib.oauth2 import LegacyApplicationClient +import urllib.parse as urlparse from ....unittest import TestCase -# this is the same import method used in oauthlib/oauth2/rfc6749/parameters.py -try: - import urlparse -except ImportError: - import urllib.parse as urlparse @patch('time.time', new=lambda: 1000) diff --git a/tests/oauth2/rfc6749/clients/test_web_application.py b/tests/oauth2/rfc6749/clients/test_web_application.py index f7fbb02..a4da237 100644 --- a/tests/oauth2/rfc6749/clients/test_web_application.py +++ b/tests/oauth2/rfc6749/clients/test_web_application.py @@ -13,14 +13,10 @@ from oauthlib.oauth2 import (BackendApplicationClient, Client, WebApplicationClient) from oauthlib.oauth2.rfc6749 import errors, utils from oauthlib.oauth2.rfc6749.clients import AUTH_HEADER, BODY, URI_QUERY +import urllib.parse as urlparse from ....unittest import TestCase -# this is the same import method used in oauthlib/oauth2/rfc6749/parameters.py -try: - import urlparse -except ImportError: - import urllib.parse as urlparse @patch('time.time', new=lambda: 1000) diff --git a/tests/oauth2/rfc6749/endpoints/test_utils.py b/tests/oauth2/rfc6749/endpoints/test_utils.py index 6b7cff8..5eae195 100644 --- a/tests/oauth2/rfc6749/endpoints/test_utils.py +++ b/tests/oauth2/rfc6749/endpoints/test_utils.py @@ -1,7 +1,4 @@ -try: - import urlparse -except ImportError: - import urllib.parse as urlparse +import urllib.parse as urlparse def get_query_credentials(uri): diff --git a/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py b/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py index 517239a..c8a707e 100644 --- a/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py +++ b/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py @@ -7,14 +7,10 @@ from oauthlib.oauth2.rfc6749.endpoints.authorization import \ AuthorizationEndpoint from oauthlib.oauth2.rfc6749.tokens import BearerToken from oauthlib.openid.connect.core.grant_types import AuthorizationCodeGrant +from urllib.parse import urlencode from tests.unittest import TestCase -try: - from urllib.parse import urlencode -except ImportError: - from urllib import urlencode - class OpenIDConnectEndpointTest(TestCase): -- cgit v1.2.1 From 9590ca26d35267f15501605c488581589f1ad91e Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 15 Aug 2019 12:21:22 +0300 Subject: Upgrade unit tests to use more useful asserts --- tests/oauth1/rfc5849/test_client.py | 2 +- tests/oauth2/rfc6749/test_server.py | 4 ++-- .../core/endpoints/test_openid_connect_params_handling.py | 2 +- .../connect/core/grant_types/test_authorization_code.py | 8 ++++---- tests/openid/connect/core/grant_types/test_hybrid.py | 6 +++--- tests/openid/connect/core/grant_types/test_implicit.py | 10 +++++----- tests/openid/connect/core/test_server.py | 4 ++-- tests/test_common.py | 12 ++++++------ 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/oauth1/rfc5849/test_client.py b/tests/oauth1/rfc5849/test_client.py index e1f83de..869d9d8 100644 --- a/tests/oauth1/rfc5849/test_client.py +++ b/tests/oauth1/rfc5849/test_client.py @@ -163,7 +163,7 @@ class SignatureMethodTest(TestCase): Client.register_signature_method('PIZZA', lambda base_string, client: 'PIZZA') - self.assertTrue('PIZZA' in Client.SIGNATURE_METHODS) + self.assertIn('PIZZA', Client.SIGNATURE_METHODS) client = Client('client_key', signature_method='PIZZA', timestamp='1234567890', nonce='abc') diff --git a/tests/oauth2/rfc6749/test_server.py b/tests/oauth2/rfc6749/test_server.py index 2c6ecff..901e461 100644 --- a/tests/oauth2/rfc6749/test_server.py +++ b/tests/oauth2/rfc6749/test_server.py @@ -73,7 +73,7 @@ class AuthorizationEndpointTest(TestCase): uri, scopes=['all', 'of', 'them']) self.assertIn('Location', headers) self.assertURLEqual(headers['Location'], 'http://back.to/me?state=xyz', parse_fragment=True) - self.assertEqual(body, None) + self.assertIsNone(body) self.assertEqual(status_code, 302) # and without the state parameter @@ -83,7 +83,7 @@ class AuthorizationEndpointTest(TestCase): uri, scopes=['all', 'of', 'them']) self.assertIn('Location', headers) self.assertURLEqual(headers['Location'], 'http://back.to/me', parse_fragment=True) - self.assertEqual(body, None) + self.assertIsNone(body) self.assertEqual(status_code, 302) def test_missing_type(self): diff --git a/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py b/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py index c8a707e..cb61780 100644 --- a/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py +++ b/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py @@ -49,7 +49,7 @@ class OpenIDConnectEndpointTest(TestCase): credentials=creds) expected = 'https://a.b/cb?state=abc&code=MOCK_CODE' self.assertURLEqual(h['Location'], expected) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) def test_prompt_none_exclusiveness(self): diff --git a/tests/openid/connect/core/grant_types/test_authorization_code.py b/tests/openid/connect/core/grant_types/test_authorization_code.py index 76a4e97..bae780b 100644 --- a/tests/openid/connect/core/grant_types/test_authorization_code.py +++ b/tests/openid/connect/core/grant_types/test_authorization_code.py @@ -66,13 +66,13 @@ class OpenIDAuthCodeTest(TestCase): self.request.response_mode = 'query' h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertURLEqual(h['Location'], self.url_query) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) self.request.response_mode = 'fragment' h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertURLEqual(h['Location'], self.url_fragment, parse_fragment=True) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) @mock.patch('oauthlib.common.generate_token') @@ -90,7 +90,7 @@ class OpenIDAuthCodeTest(TestCase): self.request.id_token_hint = 'me@email.com' h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertURLEqual(h['Location'], self.url_query) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) # Test alernative response modes @@ -159,5 +159,5 @@ class OpenIDAuthCodeTest(TestCase): self.request.response_mode = 'query' h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertURLEqual(h['Location'], self.url_query) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) diff --git a/tests/openid/connect/core/grant_types/test_hybrid.py b/tests/openid/connect/core/grant_types/test_hybrid.py index 08dcc13..66dfa85 100644 --- a/tests/openid/connect/core/grant_types/test_hybrid.py +++ b/tests/openid/connect/core/grant_types/test_hybrid.py @@ -38,7 +38,7 @@ class OpenIDHybridCodeTokenTest(OpenIDAuthCodeTest): bearer = BearerToken(self.mock_validator) h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertURLEqual(h['Location'], self.url_fragment, parse_fragment=True) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) @@ -63,7 +63,7 @@ class OpenIDHybridCodeIdTokenTest(OpenIDAuthCodeTest): bearer = BearerToken(self.mock_validator) h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertIn('error=invalid_request', h['Location']) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) @@ -88,5 +88,5 @@ class OpenIDHybridCodeIdTokenTokenTest(OpenIDAuthCodeTest): bearer = BearerToken(self.mock_validator) h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertIn('error=invalid_request', h['Location']) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) diff --git a/tests/openid/connect/core/grant_types/test_implicit.py b/tests/openid/connect/core/grant_types/test_implicit.py index e94ad30..0d04e6e 100644 --- a/tests/openid/connect/core/grant_types/test_implicit.py +++ b/tests/openid/connect/core/grant_types/test_implicit.py @@ -50,7 +50,7 @@ class OpenIDImplicitTest(TestCase): h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertURLEqual(h['Location'], self.url_fragment, parse_fragment=True) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) self.request.response_type = 'id_token' @@ -58,7 +58,7 @@ class OpenIDImplicitTest(TestCase): url = 'https://a.b/cb#state=abc&id_token=%s' % token h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertURLEqual(h['Location'], url, parse_fragment=True) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) @mock.patch('oauthlib.common.generate_token') @@ -74,7 +74,7 @@ class OpenIDImplicitTest(TestCase): self.request.id_token_hint = 'me@email.com' h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertURLEqual(h['Location'], self.url_fragment, parse_fragment=True) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) # Test alernative response modes @@ -108,7 +108,7 @@ class OpenIDImplicitTest(TestCase): bearer = BearerToken(self.mock_validator) h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertIn('error=invalid_request', h['Location']) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) @@ -129,5 +129,5 @@ class OpenIDImplicitNoAccessTokenTest(OpenIDImplicitTest): bearer = BearerToken(self.mock_validator) h, b, s = self.auth.create_authorization_response(self.request, bearer) self.assertIn('error=invalid_request', h['Location']) - self.assertEqual(b, None) + self.assertIsNone(b) self.assertEqual(s, 302) diff --git a/tests/openid/connect/core/test_server.py b/tests/openid/connect/core/test_server.py index 756c9d0..33424b4 100644 --- a/tests/openid/connect/core/test_server.py +++ b/tests/openid/connect/core/test_server.py @@ -78,7 +78,7 @@ class AuthorizationEndpointTest(TestCase): uri, scopes=['all', 'of', 'them']) self.assertIn('Location', headers) self.assertURLEqual(headers['Location'], 'http://back.to/me?state=xyz', parse_fragment=True) - self.assertEqual(body, None) + self.assertIsNone(body) self.assertEqual(status_code, 302) # and without the state parameter @@ -88,7 +88,7 @@ class AuthorizationEndpointTest(TestCase): uri, scopes=['all', 'of', 'them']) self.assertIn('Location', headers) self.assertURLEqual(headers['Location'], 'http://back.to/me', parse_fragment=True) - self.assertEqual(body, None) + self.assertIsNone(body) self.assertEqual(status_code, 302) def test_missing_type(self): diff --git a/tests/test_common.py b/tests/test_common.py index 2a9a264..5acd8e7 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -64,11 +64,11 @@ class ParameterTest(TestCase): self.assertCountEqual(extract_params([]), []) def test_extract_non_formencoded_string(self): - self.assertEqual(extract_params('not a formencoded string'), None) + self.assertIsNone(extract_params('not a formencoded string')) def test_extract_invalid(self): - self.assertEqual(extract_params(object()), None) - self.assertEqual(extract_params([('')]), None) + self.assertIsNone(extract_params(object())) + self.assertIsNone(extract_params([('')])) def test_add_params_to_uri(self): correct = '{}?{}'.format(URI, PARAMS_FORMENCODED) @@ -134,7 +134,7 @@ class RequestTest(TestCase): def test_none_body(self): r = Request(URI) - self.assertEqual(r.decoded_body, None) + self.assertIsNone(r.decoded_body) def test_empty_list_body(self): r = Request(URI, body=[]) @@ -151,12 +151,12 @@ class RequestTest(TestCase): def test_non_formencoded_string_body(self): body = 'foo bar' r = Request(URI, body=body) - self.assertEqual(r.decoded_body, None) + self.assertIsNone(r.decoded_body) def test_param_free_sequence_body(self): body = [1, 1, 2, 3, 5, 8, 13] r = Request(URI, body=body) - self.assertEqual(r.decoded_body, None) + self.assertIsNone(r.decoded_body) def test_list_body(self): r = Request(URI, body=PARAMS_TWOTUPLE) -- cgit v1.2.1 From 25dee45f9991bf009bcc5eebd5987046a4bf7779 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 15 Aug 2019 12:31:29 +0300 Subject: The future is now --- oauthlib/common.py | 2 -- oauthlib/oauth1/__init__.py | 2 -- oauthlib/oauth1/rfc5849/__init__.py | 1 - oauthlib/oauth1/rfc5849/endpoints/__init__.py | 2 -- oauthlib/oauth1/rfc5849/endpoints/access_token.py | 2 -- oauthlib/oauth1/rfc5849/endpoints/authorization.py | 2 -- oauthlib/oauth1/rfc5849/endpoints/base.py | 2 -- oauthlib/oauth1/rfc5849/endpoints/pre_configured.py | 2 -- oauthlib/oauth1/rfc5849/endpoints/request_token.py | 2 -- oauthlib/oauth1/rfc5849/endpoints/resource.py | 2 -- oauthlib/oauth1/rfc5849/endpoints/signature_only.py | 2 -- oauthlib/oauth1/rfc5849/errors.py | 2 -- oauthlib/oauth1/rfc5849/parameters.py | 2 -- oauthlib/oauth1/rfc5849/request_validator.py | 2 -- oauthlib/oauth1/rfc5849/signature.py | 2 -- oauthlib/oauth1/rfc5849/utils.py | 2 -- oauthlib/oauth2/__init__.py | 2 -- oauthlib/oauth2/rfc6749/__init__.py | 2 -- oauthlib/oauth2/rfc6749/clients/__init__.py | 2 -- oauthlib/oauth2/rfc6749/clients/backend_application.py | 2 -- oauthlib/oauth2/rfc6749/clients/base.py | 2 -- oauthlib/oauth2/rfc6749/clients/legacy_application.py | 2 -- oauthlib/oauth2/rfc6749/clients/mobile_application.py | 2 -- oauthlib/oauth2/rfc6749/clients/service_application.py | 2 -- oauthlib/oauth2/rfc6749/clients/web_application.py | 2 -- oauthlib/oauth2/rfc6749/endpoints/__init__.py | 2 -- oauthlib/oauth2/rfc6749/endpoints/authorization.py | 2 -- oauthlib/oauth2/rfc6749/endpoints/base.py | 2 -- oauthlib/oauth2/rfc6749/endpoints/introspect.py | 2 -- oauthlib/oauth2/rfc6749/endpoints/metadata.py | 2 -- oauthlib/oauth2/rfc6749/endpoints/pre_configured.py | 2 -- oauthlib/oauth2/rfc6749/endpoints/resource.py | 2 -- oauthlib/oauth2/rfc6749/endpoints/revocation.py | 2 -- oauthlib/oauth2/rfc6749/endpoints/token.py | 2 -- oauthlib/oauth2/rfc6749/errors.py | 2 -- oauthlib/oauth2/rfc6749/grant_types/__init__.py | 2 -- oauthlib/oauth2/rfc6749/grant_types/authorization_code.py | 2 -- oauthlib/oauth2/rfc6749/grant_types/base.py | 2 -- oauthlib/oauth2/rfc6749/grant_types/client_credentials.py | 2 -- oauthlib/oauth2/rfc6749/grant_types/implicit.py | 2 -- oauthlib/oauth2/rfc6749/grant_types/refresh_token.py | 2 -- .../oauth2/rfc6749/grant_types/resource_owner_password_credentials.py | 2 -- oauthlib/oauth2/rfc6749/parameters.py | 2 -- oauthlib/oauth2/rfc6749/request_validator.py | 2 -- oauthlib/oauth2/rfc6749/tokens.py | 2 -- oauthlib/oauth2/rfc6749/utils.py | 2 -- oauthlib/openid/__init__.py | 2 -- oauthlib/openid/connect/core/endpoints/__init__.py | 2 -- oauthlib/openid/connect/core/endpoints/pre_configured.py | 2 -- oauthlib/openid/connect/core/endpoints/userinfo.py | 2 -- oauthlib/openid/connect/core/exceptions.py | 2 -- oauthlib/openid/connect/core/grant_types/__init__.py | 2 -- oauthlib/openid/connect/core/grant_types/authorization_code.py | 2 -- oauthlib/openid/connect/core/grant_types/hybrid.py | 2 -- oauthlib/openid/connect/core/grant_types/implicit.py | 2 -- oauthlib/openid/connect/core/request_validator.py | 2 -- oauthlib/openid/connect/core/tokens.py | 3 --- oauthlib/uri_validate.py | 2 -- tests/oauth1/rfc5849/endpoints/test_access_token.py | 2 -- tests/oauth1/rfc5849/endpoints/test_authorization.py | 2 -- tests/oauth1/rfc5849/endpoints/test_base.py | 2 -- tests/oauth1/rfc5849/endpoints/test_request_token.py | 2 -- tests/oauth1/rfc5849/endpoints/test_resource.py | 2 -- tests/oauth1/rfc5849/endpoints/test_signature_only.py | 2 -- tests/oauth1/rfc5849/test_client.py | 2 -- tests/oauth1/rfc5849/test_parameters.py | 2 -- tests/oauth1/rfc5849/test_request_validator.py | 2 -- tests/oauth1/rfc5849/test_signatures.py | 2 -- tests/oauth1/rfc5849/test_utils.py | 2 -- tests/oauth2/rfc6749/clients/test_backend_application.py | 2 -- tests/oauth2/rfc6749/clients/test_base.py | 2 -- tests/oauth2/rfc6749/clients/test_legacy_application.py | 2 -- tests/oauth2/rfc6749/clients/test_mobile_application.py | 2 -- tests/oauth2/rfc6749/clients/test_service_application.py | 2 -- tests/oauth2/rfc6749/clients/test_web_application.py | 3 --- tests/oauth2/rfc6749/endpoints/test_base_endpoint.py | 2 -- tests/oauth2/rfc6749/endpoints/test_client_authentication.py | 2 -- tests/oauth2/rfc6749/endpoints/test_credentials_preservation.py | 2 -- tests/oauth2/rfc6749/endpoints/test_error_responses.py | 2 -- tests/oauth2/rfc6749/endpoints/test_extra_credentials.py | 2 -- tests/oauth2/rfc6749/endpoints/test_introspect_endpoint.py | 2 -- tests/oauth2/rfc6749/endpoints/test_metadata.py | 2 -- tests/oauth2/rfc6749/endpoints/test_resource_owner_association.py | 2 -- tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py | 2 -- tests/oauth2/rfc6749/endpoints/test_scope_handling.py | 2 -- tests/oauth2/rfc6749/grant_types/test_authorization_code.py | 2 -- tests/oauth2/rfc6749/grant_types/test_client_credentials.py | 2 -- tests/oauth2/rfc6749/grant_types/test_implicit.py | 2 -- tests/oauth2/rfc6749/grant_types/test_refresh_token.py | 2 -- tests/oauth2/rfc6749/grant_types/test_resource_owner_password.py | 2 -- tests/oauth2/rfc6749/test_parameters.py | 2 -- tests/oauth2/rfc6749/test_request_validator.py | 2 -- tests/oauth2/rfc6749/test_server.py | 2 -- tests/oauth2/rfc6749/test_tokens.py | 2 -- tests/oauth2/rfc6749/test_utils.py | 2 -- tests/openid/connect/core/endpoints/test_claims_handling.py | 2 -- .../connect/core/endpoints/test_openid_connect_params_handling.py | 2 -- tests/openid/connect/core/endpoints/test_userinfo_endpoint.py | 2 -- tests/openid/connect/core/grant_types/test_authorization_code.py | 2 -- tests/openid/connect/core/grant_types/test_dispatchers.py | 1 - tests/openid/connect/core/grant_types/test_hybrid.py | 2 -- tests/openid/connect/core/grant_types/test_implicit.py | 2 -- tests/openid/connect/core/test_request_validator.py | 2 -- tests/openid/connect/core/test_server.py | 2 -- tests/openid/connect/core/test_tokens.py | 2 -- tests/test_common.py | 2 -- 106 files changed, 212 deletions(-) diff --git a/oauthlib/common.py b/oauthlib/common.py index f4571ca..e7131df 100644 --- a/oauthlib/common.py +++ b/oauthlib/common.py @@ -6,8 +6,6 @@ oauthlib.common This module provides data structures and utilities common to all implementations of OAuth. """ -from __future__ import absolute_import, unicode_literals - import collections import datetime import logging diff --git a/oauthlib/oauth1/__init__.py b/oauthlib/oauth1/__init__.py index dc908d4..e6d8a80 100644 --- a/oauthlib/oauth1/__init__.py +++ b/oauthlib/oauth1/__init__.py @@ -6,8 +6,6 @@ oauthlib.oauth1 This module is a wrapper for the most recent implementation of OAuth 1.0 Client and Server classes. """ -from __future__ import absolute_import, unicode_literals - from .rfc5849 import Client from .rfc5849 import SIGNATURE_HMAC, SIGNATURE_HMAC_SHA1, SIGNATURE_HMAC_SHA256, SIGNATURE_RSA, SIGNATURE_PLAINTEXT from .rfc5849 import SIGNATURE_TYPE_AUTH_HEADER, SIGNATURE_TYPE_QUERY diff --git a/oauthlib/oauth1/rfc5849/__init__.py b/oauthlib/oauth1/rfc5849/__init__.py index da9b1ac..b629fc1 100644 --- a/oauthlib/oauth1/rfc5849/__init__.py +++ b/oauthlib/oauth1/rfc5849/__init__.py @@ -6,7 +6,6 @@ oauthlib.oauth1.rfc5849 This module is an implementation of various logic needed for signing and checking OAuth 1.0 RFC 5849 requests. """ -from __future__ import absolute_import, unicode_literals import base64 import hashlib import logging diff --git a/oauthlib/oauth1/rfc5849/endpoints/__init__.py b/oauthlib/oauth1/rfc5849/endpoints/__init__.py index b16ccba..78ade72 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/__init__.py +++ b/oauthlib/oauth1/rfc5849/endpoints/__init__.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from .base import BaseEndpoint from .request_token import RequestTokenEndpoint from .authorization import AuthorizationEndpoint diff --git a/oauthlib/oauth1/rfc5849/endpoints/access_token.py b/oauthlib/oauth1/rfc5849/endpoints/access_token.py index bea8274..13665db 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/access_token.py +++ b/oauthlib/oauth1/rfc5849/endpoints/access_token.py @@ -8,8 +8,6 @@ OAuth 1.0 RFC 5849. It validates the correctness of access token requests, creates and persists tokens as well as create the proper response to be returned to the client. """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib.common import urlencode diff --git a/oauthlib/oauth1/rfc5849/endpoints/authorization.py b/oauthlib/oauth1/rfc5849/endpoints/authorization.py index 945da74..7d0353b 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/authorization.py +++ b/oauthlib/oauth1/rfc5849/endpoints/authorization.py @@ -6,8 +6,6 @@ oauthlib.oauth1.rfc5849.endpoints.authorization This module is an implementation of various logic needed for signing and checking OAuth 1.0 RFC 5849 requests. """ -from __future__ import absolute_import, unicode_literals - from oauthlib.common import Request, add_params_to_uri from .. import errors diff --git a/oauthlib/oauth1/rfc5849/endpoints/base.py b/oauthlib/oauth1/rfc5849/endpoints/base.py index c6428ea..f9a8f57 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/base.py +++ b/oauthlib/oauth1/rfc5849/endpoints/base.py @@ -6,8 +6,6 @@ oauthlib.oauth1.rfc5849.endpoints.base This module is an implementation of various logic needed for signing and checking OAuth 1.0 RFC 5849 requests. """ -from __future__ import absolute_import, unicode_literals - import time from oauthlib.common import CaseInsensitiveDict, Request, generate_token diff --git a/oauthlib/oauth1/rfc5849/endpoints/pre_configured.py b/oauthlib/oauth1/rfc5849/endpoints/pre_configured.py index f89393a..b14a6d8 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/pre_configured.py +++ b/oauthlib/oauth1/rfc5849/endpoints/pre_configured.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - from . import (AccessTokenEndpoint, AuthorizationEndpoint, RequestTokenEndpoint, ResourceEndpoint) diff --git a/oauthlib/oauth1/rfc5849/endpoints/request_token.py b/oauthlib/oauth1/rfc5849/endpoints/request_token.py index 6749755..bb67e71 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/request_token.py +++ b/oauthlib/oauth1/rfc5849/endpoints/request_token.py @@ -8,8 +8,6 @@ OAuth 1.0 RFC 5849. It validates the correctness of request token requests, creates and persists tokens as well as create the proper response to be returned to the client. """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib.common import urlencode diff --git a/oauthlib/oauth1/rfc5849/endpoints/resource.py b/oauthlib/oauth1/rfc5849/endpoints/resource.py index f82e8b1..45bdaaa 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/resource.py +++ b/oauthlib/oauth1/rfc5849/endpoints/resource.py @@ -6,8 +6,6 @@ oauthlib.oauth1.rfc5849.endpoints.resource This module is an implementation of the resource protection provider logic of OAuth 1.0 RFC 5849. """ -from __future__ import absolute_import, unicode_literals - import logging from .. import errors diff --git a/oauthlib/oauth1/rfc5849/endpoints/signature_only.py b/oauthlib/oauth1/rfc5849/endpoints/signature_only.py index 4297770..d693ccb 100644 --- a/oauthlib/oauth1/rfc5849/endpoints/signature_only.py +++ b/oauthlib/oauth1/rfc5849/endpoints/signature_only.py @@ -6,8 +6,6 @@ oauthlib.oauth1.rfc5849.endpoints.signature_only This module is an implementation of the signing logic of OAuth 1.0 RFC 5849. """ -from __future__ import absolute_import, unicode_literals - import logging from .. import errors diff --git a/oauthlib/oauth1/rfc5849/errors.py b/oauthlib/oauth1/rfc5849/errors.py index f8c2281..98d327f 100644 --- a/oauthlib/oauth1/rfc5849/errors.py +++ b/oauthlib/oauth1/rfc5849/errors.py @@ -6,8 +6,6 @@ oauthlib.oauth1.rfc5849.errors Error used both by OAuth 1 clients and provicers to represent the spec defined error responses for all four core grant types. """ -from __future__ import unicode_literals - from oauthlib.common import add_params_to_uri, urlencode diff --git a/oauthlib/oauth1/rfc5849/parameters.py b/oauthlib/oauth1/rfc5849/parameters.py index 95e07d5..778a46d 100644 --- a/oauthlib/oauth1/rfc5849/parameters.py +++ b/oauthlib/oauth1/rfc5849/parameters.py @@ -7,8 +7,6 @@ This module contains methods related to `section 3.5`_ of the OAuth 1.0a spec. .. _`section 3.5`: https://tools.ietf.org/html/rfc5849#section-3.5 """ -from __future__ import absolute_import, unicode_literals - from oauthlib.common import extract_params, urlencode from . import utils diff --git a/oauthlib/oauth1/rfc5849/request_validator.py b/oauthlib/oauth1/rfc5849/request_validator.py index db5f1dd..657bfe3 100644 --- a/oauthlib/oauth1/rfc5849/request_validator.py +++ b/oauthlib/oauth1/rfc5849/request_validator.py @@ -6,8 +6,6 @@ oauthlib.oauth1.rfc5849 This module is an implementation of various logic needed for signing and checking OAuth 1.0 RFC 5849 requests. """ -from __future__ import absolute_import, unicode_literals - import sys from . import SIGNATURE_METHODS, utils diff --git a/oauthlib/oauth1/rfc5849/signature.py b/oauthlib/oauth1/rfc5849/signature.py index ea6ab39..43688cb 100644 --- a/oauthlib/oauth1/rfc5849/signature.py +++ b/oauthlib/oauth1/rfc5849/signature.py @@ -21,8 +21,6 @@ Steps for signing a request: .. _`section 3.4`: https://tools.ietf.org/html/rfc5849#section-3.4 """ -from __future__ import absolute_import, unicode_literals - import binascii import hashlib import hmac diff --git a/oauthlib/oauth1/rfc5849/utils.py b/oauthlib/oauth1/rfc5849/utils.py index 2dfc1f7..28e006a 100644 --- a/oauthlib/oauth1/rfc5849/utils.py +++ b/oauthlib/oauth1/rfc5849/utils.py @@ -6,8 +6,6 @@ oauthlib.utils This module contains utility methods used by various parts of the OAuth spec. """ -from __future__ import absolute_import, unicode_literals - from oauthlib.common import quote, unquote import urllib.request as urllib2 diff --git a/oauthlib/oauth2/__init__.py b/oauthlib/oauth2/__init__.py index 3f43755..9186800 100644 --- a/oauthlib/oauth2/__init__.py +++ b/oauthlib/oauth2/__init__.py @@ -6,8 +6,6 @@ oauthlib.oauth2 This module is a wrapper for the most recent implementation of OAuth 2.0 Client and Server classes. """ -from __future__ import absolute_import, unicode_literals - from .rfc6749.clients import Client from .rfc6749.clients import WebApplicationClient from .rfc6749.clients import MobileApplicationClient diff --git a/oauthlib/oauth2/rfc6749/__init__.py b/oauthlib/oauth2/rfc6749/__init__.py index 1a4128c..1c11234 100644 --- a/oauthlib/oauth2/rfc6749/__init__.py +++ b/oauthlib/oauth2/rfc6749/__init__.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - import functools import logging diff --git a/oauthlib/oauth2/rfc6749/clients/__init__.py b/oauthlib/oauth2/rfc6749/clients/__init__.py index 17d0023..6fef738 100644 --- a/oauthlib/oauth2/rfc6749/clients/__init__.py +++ b/oauthlib/oauth2/rfc6749/clients/__init__.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - from .base import Client, AUTH_HEADER, URI_QUERY, BODY from .web_application import WebApplicationClient from .mobile_application import MobileApplicationClient diff --git a/oauthlib/oauth2/rfc6749/clients/backend_application.py b/oauthlib/oauth2/rfc6749/clients/backend_application.py index 5737814..5ffe6ae 100644 --- a/oauthlib/oauth2/rfc6749/clients/backend_application.py +++ b/oauthlib/oauth2/rfc6749/clients/backend_application.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - from ..parameters import parse_token_response, prepare_token_request from .base import Client diff --git a/oauthlib/oauth2/rfc6749/clients/base.py b/oauthlib/oauth2/rfc6749/clients/base.py index c028552..04dabe6 100644 --- a/oauthlib/oauth2/rfc6749/clients/base.py +++ b/oauthlib/oauth2/rfc6749/clients/base.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - import time import warnings diff --git a/oauthlib/oauth2/rfc6749/clients/legacy_application.py b/oauthlib/oauth2/rfc6749/clients/legacy_application.py index c224c33..1bb0e14 100644 --- a/oauthlib/oauth2/rfc6749/clients/legacy_application.py +++ b/oauthlib/oauth2/rfc6749/clients/legacy_application.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - from ..parameters import parse_token_response, prepare_token_request from .base import Client diff --git a/oauthlib/oauth2/rfc6749/clients/mobile_application.py b/oauthlib/oauth2/rfc6749/clients/mobile_application.py index 11c6c51..73627c4 100644 --- a/oauthlib/oauth2/rfc6749/clients/mobile_application.py +++ b/oauthlib/oauth2/rfc6749/clients/mobile_application.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - from ..parameters import parse_implicit_response, prepare_grant_uri from .base import Client diff --git a/oauthlib/oauth2/rfc6749/clients/service_application.py b/oauthlib/oauth2/rfc6749/clients/service_application.py index 00ea018..09fc7ba 100644 --- a/oauthlib/oauth2/rfc6749/clients/service_application.py +++ b/oauthlib/oauth2/rfc6749/clients/service_application.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - import time from oauthlib.common import to_unicode diff --git a/oauthlib/oauth2/rfc6749/clients/web_application.py b/oauthlib/oauth2/rfc6749/clients/web_application.py index fe64ef0..aedc9d1 100644 --- a/oauthlib/oauth2/rfc6749/clients/web_application.py +++ b/oauthlib/oauth2/rfc6749/clients/web_application.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - import warnings from ..parameters import (parse_authorization_code_response, diff --git a/oauthlib/oauth2/rfc6749/endpoints/__init__.py b/oauthlib/oauth2/rfc6749/endpoints/__init__.py index 51e173d..49e7ee9 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/__init__.py +++ b/oauthlib/oauth2/rfc6749/endpoints/__init__.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - from .authorization import AuthorizationEndpoint from .introspect import IntrospectEndpoint from .metadata import MetadataEndpoint diff --git a/oauthlib/oauth2/rfc6749/endpoints/authorization.py b/oauthlib/oauth2/rfc6749/endpoints/authorization.py index 92cde34..fd77f46 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/authorization.py +++ b/oauthlib/oauth2/rfc6749/endpoints/authorization.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib.common import Request diff --git a/oauthlib/oauth2/rfc6749/endpoints/base.py b/oauthlib/oauth2/rfc6749/endpoints/base.py index e69ccf0..5169517 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/base.py +++ b/oauthlib/oauth2/rfc6749/endpoints/base.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - import functools import logging diff --git a/oauthlib/oauth2/rfc6749/endpoints/introspect.py b/oauthlib/oauth2/rfc6749/endpoints/introspect.py index 4accbdc..bad8950 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/introspect.py +++ b/oauthlib/oauth2/rfc6749/endpoints/introspect.py @@ -7,8 +7,6 @@ An implementation of the OAuth 2.0 `Token Introspection`. .. _`Token Introspection`: https://tools.ietf.org/html/rfc7662 """ -from __future__ import absolute_import, unicode_literals - import json import logging diff --git a/oauthlib/oauth2/rfc6749/endpoints/metadata.py b/oauthlib/oauth2/rfc6749/endpoints/metadata.py index d3ff1d7..6bc078d 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/metadata.py +++ b/oauthlib/oauth2/rfc6749/endpoints/metadata.py @@ -7,8 +7,6 @@ An implementation of the `OAuth 2.0 Authorization Server Metadata`. .. _`OAuth 2.0 Authorization Server Metadata`: https://tools.ietf.org/html/rfc8414 """ -from __future__ import absolute_import, unicode_literals - import copy import json import logging diff --git a/oauthlib/oauth2/rfc6749/endpoints/pre_configured.py b/oauthlib/oauth2/rfc6749/endpoints/pre_configured.py index e2cc9db..1855973 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/pre_configured.py +++ b/oauthlib/oauth2/rfc6749/endpoints/pre_configured.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749.endpoints.pre_configured This module is an implementation of various endpoints needed for providing OAuth 2.0 RFC6749 servers. """ -from __future__ import absolute_import, unicode_literals - from ..grant_types import (AuthorizationCodeGrant, ClientCredentialsGrant, ImplicitGrant, diff --git a/oauthlib/oauth2/rfc6749/endpoints/resource.py b/oauthlib/oauth2/rfc6749/endpoints/resource.py index f19c60c..76e57b1 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/resource.py +++ b/oauthlib/oauth2/rfc6749/endpoints/resource.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib.common import Request diff --git a/oauthlib/oauth2/rfc6749/endpoints/revocation.py b/oauthlib/oauth2/rfc6749/endpoints/revocation.py index cda6375..ed245f3 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/revocation.py +++ b/oauthlib/oauth2/rfc6749/endpoints/revocation.py @@ -7,8 +7,6 @@ An implementation of the OAuth 2 `Token Revocation`_ spec (draft 11). .. _`Token Revocation`: https://tools.ietf.org/html/draft-ietf-oauth-revocation-11 """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib.common import Request diff --git a/oauthlib/oauth2/rfc6749/endpoints/token.py b/oauthlib/oauth2/rfc6749/endpoints/token.py index bc87e9b..2b2d495 100644 --- a/oauthlib/oauth2/rfc6749/endpoints/token.py +++ b/oauthlib/oauth2/rfc6749/endpoints/token.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749 This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib.common import Request diff --git a/oauthlib/oauth2/rfc6749/errors.py b/oauthlib/oauth2/rfc6749/errors.py index 8f88bb4..9896303 100644 --- a/oauthlib/oauth2/rfc6749/errors.py +++ b/oauthlib/oauth2/rfc6749/errors.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749.errors Error used both by OAuth 2 clients and providers to represent the spec defined error responses for all four core grant types. """ -from __future__ import unicode_literals - import json from oauthlib.common import add_params_to_uri, urlencode diff --git a/oauthlib/oauth2/rfc6749/grant_types/__init__.py b/oauthlib/oauth2/rfc6749/grant_types/__init__.py index 2ec8e4f..30c90d7 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/__init__.py +++ b/oauthlib/oauth2/rfc6749/grant_types/__init__.py @@ -3,8 +3,6 @@ oauthlib.oauth2.rfc6749.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import unicode_literals, absolute_import - from .authorization_code import AuthorizationCodeGrant from .implicit import ImplicitGrant from .resource_owner_password_credentials import ResourceOwnerPasswordCredentialsGrant diff --git a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py index 9b84c4c..f4bde86 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +++ b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py @@ -3,8 +3,6 @@ oauthlib.oauth2.rfc6749.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import base64 import hashlib import json diff --git a/oauthlib/oauth2/rfc6749/grant_types/base.py b/oauthlib/oauth2/rfc6749/grant_types/base.py index b4c3665..66e1fd1 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/base.py +++ b/oauthlib/oauth2/rfc6749/grant_types/base.py @@ -3,8 +3,6 @@ oauthlib.oauth2.rfc6749.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import logging from itertools import chain diff --git a/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py b/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py index 7e50857..fdb0bf6 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py +++ b/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py @@ -3,8 +3,6 @@ oauthlib.oauth2.rfc6749.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import json import logging diff --git a/oauthlib/oauth2/rfc6749/grant_types/implicit.py b/oauthlib/oauth2/rfc6749/grant_types/implicit.py index 48bae7a..335e58c 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/implicit.py +++ b/oauthlib/oauth2/rfc6749/grant_types/implicit.py @@ -3,8 +3,6 @@ oauthlib.oauth2.rfc6749.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib import common diff --git a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py index 5f0db28..e7405d2 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py +++ b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py @@ -3,8 +3,6 @@ oauthlib.oauth2.rfc6749.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import json import logging diff --git a/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py b/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py index 5929afb..9c8ee1d 100644 --- a/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py +++ b/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py @@ -3,8 +3,6 @@ oauthlib.oauth2.rfc6749.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import json import logging diff --git a/oauthlib/oauth2/rfc6749/parameters.py b/oauthlib/oauth2/rfc6749/parameters.py index 2bca4d2..54c8d24 100644 --- a/oauthlib/oauth2/rfc6749/parameters.py +++ b/oauthlib/oauth2/rfc6749/parameters.py @@ -7,8 +7,6 @@ This module contains methods related to `Section 4`_ of the OAuth 2 RFC. .. _`Section 4`: https://tools.ietf.org/html/rfc6749#section-4 """ -from __future__ import absolute_import, unicode_literals - import json import os import time diff --git a/oauthlib/oauth2/rfc6749/request_validator.py b/oauthlib/oauth2/rfc6749/request_validator.py index eeef50e..78d025b 100644 --- a/oauthlib/oauth2/rfc6749/request_validator.py +++ b/oauthlib/oauth2/rfc6749/request_validator.py @@ -3,8 +3,6 @@ oauthlib.oauth2.rfc6749.request_validator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import logging log = logging.getLogger(__name__) diff --git a/oauthlib/oauth2/rfc6749/tokens.py b/oauthlib/oauth2/rfc6749/tokens.py index 8e139f6..6f6b1f6 100644 --- a/oauthlib/oauth2/rfc6749/tokens.py +++ b/oauthlib/oauth2/rfc6749/tokens.py @@ -7,8 +7,6 @@ This module contains methods for adding two types of access tokens to requests. - Bearer https://tools.ietf.org/html/rfc6750 - MAC https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01 """ -from __future__ import absolute_import, unicode_literals - import hashlib import hmac from binascii import b2a_base64 diff --git a/oauthlib/oauth2/rfc6749/utils.py b/oauthlib/oauth2/rfc6749/utils.py index efbf8aa..3117d4b 100644 --- a/oauthlib/oauth2/rfc6749/utils.py +++ b/oauthlib/oauth2/rfc6749/utils.py @@ -5,8 +5,6 @@ oauthlib.utils This module contains utility methods used by various parts of the OAuth 2 spec. """ -from __future__ import absolute_import, unicode_literals - import datetime import os diff --git a/oauthlib/openid/__init__.py b/oauthlib/openid/__init__.py index 8157c29..fb1ac8d 100644 --- a/oauthlib/openid/__init__.py +++ b/oauthlib/openid/__init__.py @@ -4,8 +4,6 @@ oauthlib.openid ~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - from .connect.core.endpoints import Server from .connect.core.endpoints import UserInfoEndpoint from .connect.core.request_validator import RequestValidator diff --git a/oauthlib/openid/connect/core/endpoints/__init__.py b/oauthlib/openid/connect/core/endpoints/__init__.py index 528841f..92f1ba9 100644 --- a/oauthlib/openid/connect/core/endpoints/__init__.py +++ b/oauthlib/openid/connect/core/endpoints/__init__.py @@ -6,7 +6,5 @@ oauthlib.oopenid.core This module is an implementation of various logic needed for consuming and providing OpenID Connect """ -from __future__ import absolute_import, unicode_literals - from .pre_configured import Server from .userinfo import UserInfoEndpoint diff --git a/oauthlib/openid/connect/core/endpoints/pre_configured.py b/oauthlib/openid/connect/core/endpoints/pre_configured.py index fde2739..ad2faa7 100644 --- a/oauthlib/openid/connect/core/endpoints/pre_configured.py +++ b/oauthlib/openid/connect/core/endpoints/pre_configured.py @@ -6,8 +6,6 @@ oauthlib.openid.connect.core.endpoints.pre_configured This module is an implementation of various endpoints needed for providing OpenID Connect servers. """ -from __future__ import absolute_import, unicode_literals - from oauthlib.oauth2.rfc6749.endpoints import ( AuthorizationEndpoint, IntrospectEndpoint, diff --git a/oauthlib/openid/connect/core/endpoints/userinfo.py b/oauthlib/openid/connect/core/endpoints/userinfo.py index d7387fe..dc73373 100644 --- a/oauthlib/openid/connect/core/endpoints/userinfo.py +++ b/oauthlib/openid/connect/core/endpoints/userinfo.py @@ -4,8 +4,6 @@ oauthlib.openid.connect.core.endpoints.userinfo This module is an implementation of userinfo endpoint. """ -from __future__ import absolute_import, unicode_literals - import json import logging diff --git a/oauthlib/openid/connect/core/exceptions.py b/oauthlib/openid/connect/core/exceptions.py index 8b08d21..aa795e0 100644 --- a/oauthlib/openid/connect/core/exceptions.py +++ b/oauthlib/openid/connect/core/exceptions.py @@ -6,8 +6,6 @@ oauthlib.oauth2.rfc6749.errors Error used both by OAuth 2 clients and providers to represent the spec defined error responses for all four core grant types. """ -from __future__ import unicode_literals - from oauthlib.oauth2.rfc6749.errors import FatalClientError, OAuth2Error diff --git a/oauthlib/openid/connect/core/grant_types/__init__.py b/oauthlib/openid/connect/core/grant_types/__init__.py index 63f30ac..4e7b474 100644 --- a/oauthlib/openid/connect/core/grant_types/__init__.py +++ b/oauthlib/openid/connect/core/grant_types/__init__.py @@ -3,8 +3,6 @@ oauthlib.openid.connect.core.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import unicode_literals, absolute_import - from .authorization_code import AuthorizationCodeGrant from .implicit import ImplicitGrant from .base import GrantTypeBase diff --git a/oauthlib/openid/connect/core/grant_types/authorization_code.py b/oauthlib/openid/connect/core/grant_types/authorization_code.py index 7047e1e..d07d138 100644 --- a/oauthlib/openid/connect/core/grant_types/authorization_code.py +++ b/oauthlib/openid/connect/core/grant_types/authorization_code.py @@ -3,8 +3,6 @@ oauthlib.openid.connect.core.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib.oauth2.rfc6749.grant_types.authorization_code import AuthorizationCodeGrant as OAuth2AuthorizationCodeGrant diff --git a/oauthlib/openid/connect/core/grant_types/hybrid.py b/oauthlib/openid/connect/core/grant_types/hybrid.py index af86d10..caf8547 100644 --- a/oauthlib/openid/connect/core/grant_types/hybrid.py +++ b/oauthlib/openid/connect/core/grant_types/hybrid.py @@ -3,8 +3,6 @@ oauthlib.openid.connect.core.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib.oauth2.rfc6749.grant_types.authorization_code import AuthorizationCodeGrant as OAuth2AuthorizationCodeGrant diff --git a/oauthlib/openid/connect/core/grant_types/implicit.py b/oauthlib/openid/connect/core/grant_types/implicit.py index aefec57..62f63f9 100644 --- a/oauthlib/openid/connect/core/grant_types/implicit.py +++ b/oauthlib/openid/connect/core/grant_types/implicit.py @@ -3,8 +3,6 @@ oauthlib.openid.connect.core.grant_types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import logging from .base import GrantTypeBase diff --git a/oauthlib/openid/connect/core/request_validator.py b/oauthlib/openid/connect/core/request_validator.py index e853d39..ebc07dc 100644 --- a/oauthlib/openid/connect/core/request_validator.py +++ b/oauthlib/openid/connect/core/request_validator.py @@ -3,8 +3,6 @@ oauthlib.openid.connect.core.request_validator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ -from __future__ import absolute_import, unicode_literals - import logging from oauthlib.oauth2.rfc6749.request_validator import RequestValidator as OAuth2RequestValidator diff --git a/oauthlib/openid/connect/core/tokens.py b/oauthlib/openid/connect/core/tokens.py index b67cdf2..d24cb56 100644 --- a/oauthlib/openid/connect/core/tokens.py +++ b/oauthlib/openid/connect/core/tokens.py @@ -4,9 +4,6 @@ authlib.openid.connect.core.tokens This module contains methods for adding JWT tokens to requests. """ -from __future__ import absolute_import, unicode_literals - - from oauthlib.oauth2.rfc6749.tokens import TokenBase, random_token_generator diff --git a/oauthlib/uri_validate.py b/oauthlib/uri_validate.py index ce8ea40..93b6131 100644 --- a/oauthlib/uri_validate.py +++ b/oauthlib/uri_validate.py @@ -8,8 +8,6 @@ They should be processed with re.VERBOSE. Thanks Mark Nottingham for this code - https://gist.github.com/138549 """ -from __future__ import unicode_literals - import re # basics diff --git a/tests/oauth1/rfc5849/endpoints/test_access_token.py b/tests/oauth1/rfc5849/endpoints/test_access_token.py index 3499fdb..9ba8a3e 100644 --- a/tests/oauth1/rfc5849/endpoints/test_access_token.py +++ b/tests/oauth1/rfc5849/endpoints/test_access_token.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - from mock import ANY, MagicMock from oauthlib.oauth1 import RequestValidator diff --git a/tests/oauth1/rfc5849/endpoints/test_authorization.py b/tests/oauth1/rfc5849/endpoints/test_authorization.py index e9d3604..178bddf 100644 --- a/tests/oauth1/rfc5849/endpoints/test_authorization.py +++ b/tests/oauth1/rfc5849/endpoints/test_authorization.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - from mock import MagicMock from oauthlib.oauth1 import RequestValidator diff --git a/tests/oauth1/rfc5849/endpoints/test_base.py b/tests/oauth1/rfc5849/endpoints/test_base.py index 795ddee..de6c1a4 100644 --- a/tests/oauth1/rfc5849/endpoints/test_base.py +++ b/tests/oauth1/rfc5849/endpoints/test_base.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - from re import sub from mock import MagicMock diff --git a/tests/oauth1/rfc5849/endpoints/test_request_token.py b/tests/oauth1/rfc5849/endpoints/test_request_token.py index 5c9ae88..ece36bd 100644 --- a/tests/oauth1/rfc5849/endpoints/test_request_token.py +++ b/tests/oauth1/rfc5849/endpoints/test_request_token.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - from mock import ANY, MagicMock from oauthlib.oauth1 import RequestValidator diff --git a/tests/oauth1/rfc5849/endpoints/test_resource.py b/tests/oauth1/rfc5849/endpoints/test_resource.py index b71412a..41c9aee 100644 --- a/tests/oauth1/rfc5849/endpoints/test_resource.py +++ b/tests/oauth1/rfc5849/endpoints/test_resource.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - from mock import ANY, MagicMock from oauthlib.oauth1 import RequestValidator diff --git a/tests/oauth1/rfc5849/endpoints/test_signature_only.py b/tests/oauth1/rfc5849/endpoints/test_signature_only.py index 1d758b1..9804137 100644 --- a/tests/oauth1/rfc5849/endpoints/test_signature_only.py +++ b/tests/oauth1/rfc5849/endpoints/test_signature_only.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - from mock import ANY, MagicMock from oauthlib.oauth1 import RequestValidator diff --git a/tests/oauth1/rfc5849/test_client.py b/tests/oauth1/rfc5849/test_client.py index 869d9d8..5c805a1 100644 --- a/tests/oauth1/rfc5849/test_client.py +++ b/tests/oauth1/rfc5849/test_client.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from oauthlib.common import Request from oauthlib.oauth1 import (SIGNATURE_PLAINTEXT, SIGNATURE_HMAC_SHA1, SIGNATURE_HMAC_SHA256, SIGNATURE_RSA, diff --git a/tests/oauth1/rfc5849/test_parameters.py b/tests/oauth1/rfc5849/test_parameters.py index ae72fd7..3afbb3a 100644 --- a/tests/oauth1/rfc5849/test_parameters.py +++ b/tests/oauth1/rfc5849/test_parameters.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from oauthlib.common import urlencode from oauthlib.oauth1.rfc5849.parameters import (_append_params, prepare_form_encoded_body, diff --git a/tests/oauth1/rfc5849/test_request_validator.py b/tests/oauth1/rfc5849/test_request_validator.py index 88bbcdc..a3fe58f 100644 --- a/tests/oauth1/rfc5849/test_request_validator.py +++ b/tests/oauth1/rfc5849/test_request_validator.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from oauthlib.oauth1 import RequestValidator from ...unittest import TestCase diff --git a/tests/oauth1/rfc5849/test_signatures.py b/tests/oauth1/rfc5849/test_signatures.py index 48a17c4..2c1700f 100644 --- a/tests/oauth1/rfc5849/test_signatures.py +++ b/tests/oauth1/rfc5849/test_signatures.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from oauthlib.oauth1.rfc5849.signature import (collect_parameters, signature_base_string, base_string_uri, diff --git a/tests/oauth1/rfc5849/test_utils.py b/tests/oauth1/rfc5849/test_utils.py index 1db2659..ba8ed0e 100644 --- a/tests/oauth1/rfc5849/test_utils.py +++ b/tests/oauth1/rfc5849/test_utils.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from oauthlib.oauth1.rfc5849.utils import * from ...unittest import TestCase diff --git a/tests/oauth2/rfc6749/clients/test_backend_application.py b/tests/oauth2/rfc6749/clients/test_backend_application.py index aa2ba2b..8d80b39 100644 --- a/tests/oauth2/rfc6749/clients/test_backend_application.py +++ b/tests/oauth2/rfc6749/clients/test_backend_application.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import os from mock import patch diff --git a/tests/oauth2/rfc6749/clients/test_base.py b/tests/oauth2/rfc6749/clients/test_base.py index 4fbada9..c545c25 100644 --- a/tests/oauth2/rfc6749/clients/test_base.py +++ b/tests/oauth2/rfc6749/clients/test_base.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import datetime from oauthlib import common diff --git a/tests/oauth2/rfc6749/clients/test_legacy_application.py b/tests/oauth2/rfc6749/clients/test_legacy_application.py index 20fb24b..34ea108 100644 --- a/tests/oauth2/rfc6749/clients/test_legacy_application.py +++ b/tests/oauth2/rfc6749/clients/test_legacy_application.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import os from mock import patch diff --git a/tests/oauth2/rfc6749/clients/test_mobile_application.py b/tests/oauth2/rfc6749/clients/test_mobile_application.py index 622b275..e2bdebe 100644 --- a/tests/oauth2/rfc6749/clients/test_mobile_application.py +++ b/tests/oauth2/rfc6749/clients/test_mobile_application.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import os from mock import patch diff --git a/tests/oauth2/rfc6749/clients/test_service_application.py b/tests/oauth2/rfc6749/clients/test_service_application.py index dc337cf..ba9406b 100644 --- a/tests/oauth2/rfc6749/clients/test_service_application.py +++ b/tests/oauth2/rfc6749/clients/test_service_application.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import os from time import time diff --git a/tests/oauth2/rfc6749/clients/test_web_application.py b/tests/oauth2/rfc6749/clients/test_web_application.py index a4da237..e3382c8 100644 --- a/tests/oauth2/rfc6749/clients/test_web_application.py +++ b/tests/oauth2/rfc6749/clients/test_web_application.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - -import datetime import os import warnings diff --git a/tests/oauth2/rfc6749/endpoints/test_base_endpoint.py b/tests/oauth2/rfc6749/endpoints/test_base_endpoint.py index bf04a42..2289b58 100644 --- a/tests/oauth2/rfc6749/endpoints/test_base_endpoint.py +++ b/tests/oauth2/rfc6749/endpoints/test_base_endpoint.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from oauthlib.oauth2 import (FatalClientError, OAuth2Error, RequestValidator, Server) from oauthlib.oauth2.rfc6749 import (BaseEndpoint, diff --git a/tests/oauth2/rfc6749/endpoints/test_client_authentication.py b/tests/oauth2/rfc6749/endpoints/test_client_authentication.py index 133da59..48b5485 100644 --- a/tests/oauth2/rfc6749/endpoints/test_client_authentication.py +++ b/tests/oauth2/rfc6749/endpoints/test_client_authentication.py @@ -9,8 +9,6 @@ We make sure authentication is done by requiring a client object to be set on the request object with a client_id parameter. The client_id attribute prevents this check from being circumvented with a client form parameter. """ -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/endpoints/test_credentials_preservation.py b/tests/oauth2/rfc6749/endpoints/test_credentials_preservation.py index e7c66b6..bda71f7 100644 --- a/tests/oauth2/rfc6749/endpoints/test_credentials_preservation.py +++ b/tests/oauth2/rfc6749/endpoints/test_credentials_preservation.py @@ -3,8 +3,6 @@ The Authorization Code Grant will need to preserve state as well as redirect uri and the Implicit Grant will need to preserve state. """ -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/endpoints/test_error_responses.py b/tests/oauth2/rfc6749/endpoints/test_error_responses.py index 2479836..cdf2b63 100644 --- a/tests/oauth2/rfc6749/endpoints/test_error_responses.py +++ b/tests/oauth2/rfc6749/endpoints/test_error_responses.py @@ -1,7 +1,5 @@ """Ensure the correct error responses are returned for all defined error types. """ -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/endpoints/test_extra_credentials.py b/tests/oauth2/rfc6749/endpoints/test_extra_credentials.py index a12fcd2..6895dcd 100644 --- a/tests/oauth2/rfc6749/endpoints/test_extra_credentials.py +++ b/tests/oauth2/rfc6749/endpoints/test_extra_credentials.py @@ -1,7 +1,5 @@ """Ensure extra credentials can be supplied for inclusion in tokens. """ -from __future__ import absolute_import, unicode_literals - import mock from oauthlib.oauth2 import (BackendApplicationServer, LegacyApplicationServer, diff --git a/tests/oauth2/rfc6749/endpoints/test_introspect_endpoint.py b/tests/oauth2/rfc6749/endpoints/test_introspect_endpoint.py index ae3deae..0942d96 100644 --- a/tests/oauth2/rfc6749/endpoints/test_introspect_endpoint.py +++ b/tests/oauth2/rfc6749/endpoints/test_introspect_endpoint.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from json import loads from mock import MagicMock diff --git a/tests/oauth2/rfc6749/endpoints/test_metadata.py b/tests/oauth2/rfc6749/endpoints/test_metadata.py index 4813b46..a01500f 100644 --- a/tests/oauth2/rfc6749/endpoints/test_metadata.py +++ b/tests/oauth2/rfc6749/endpoints/test_metadata.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from oauthlib.oauth2 import MetadataEndpoint from oauthlib.oauth2 import TokenEndpoint from oauthlib.oauth2 import Server diff --git a/tests/oauth2/rfc6749/endpoints/test_resource_owner_association.py b/tests/oauth2/rfc6749/endpoints/test_resource_owner_association.py index e823286..9e9d836 100644 --- a/tests/oauth2/rfc6749/endpoints/test_resource_owner_association.py +++ b/tests/oauth2/rfc6749/endpoints/test_resource_owner_association.py @@ -1,7 +1,5 @@ """Ensure all tokens are associated with a resource owner. """ -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py b/tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py index 17be3a5..0e3b2e1 100644 --- a/tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py +++ b/tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from json import loads from mock import MagicMock diff --git a/tests/oauth2/rfc6749/endpoints/test_scope_handling.py b/tests/oauth2/rfc6749/endpoints/test_scope_handling.py index b235bd7..65e0e3c 100644 --- a/tests/oauth2/rfc6749/endpoints/test_scope_handling.py +++ b/tests/oauth2/rfc6749/endpoints/test_scope_handling.py @@ -3,8 +3,6 @@ Fairly trivial in all grants except the Authorization Code Grant where scope need to be persisted temporarily in an authorization code. """ -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/grant_types/test_authorization_code.py b/tests/oauth2/rfc6749/grant_types/test_authorization_code.py index 2c9db3c..4ed9086 100644 --- a/tests/oauth2/rfc6749/grant_types/test_authorization_code.py +++ b/tests/oauth2/rfc6749/grant_types/test_authorization_code.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/grant_types/test_client_credentials.py b/tests/oauth2/rfc6749/grant_types/test_client_credentials.py index edc6bfe..d994278 100644 --- a/tests/oauth2/rfc6749/grant_types/test_client_credentials.py +++ b/tests/oauth2/rfc6749/grant_types/test_client_credentials.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/grant_types/test_implicit.py b/tests/oauth2/rfc6749/grant_types/test_implicit.py index 0c18cab..ffd766a 100644 --- a/tests/oauth2/rfc6749/grant_types/test_implicit.py +++ b/tests/oauth2/rfc6749/grant_types/test_implicit.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import mock from oauthlib.common import Request diff --git a/tests/oauth2/rfc6749/grant_types/test_refresh_token.py b/tests/oauth2/rfc6749/grant_types/test_refresh_token.py index 32a0977..074f359 100644 --- a/tests/oauth2/rfc6749/grant_types/test_refresh_token.py +++ b/tests/oauth2/rfc6749/grant_types/test_refresh_token.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/grant_types/test_resource_owner_password.py b/tests/oauth2/rfc6749/grant_types/test_resource_owner_password.py index 82e0524..4e93015 100644 --- a/tests/oauth2/rfc6749/grant_types/test_resource_owner_password.py +++ b/tests/oauth2/rfc6749/grant_types/test_resource_owner_password.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/test_parameters.py b/tests/oauth2/rfc6749/test_parameters.py index 5e449f4..e9b3621 100644 --- a/tests/oauth2/rfc6749/test_parameters.py +++ b/tests/oauth2/rfc6749/test_parameters.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - from mock import patch from oauthlib import signals diff --git a/tests/oauth2/rfc6749/test_request_validator.py b/tests/oauth2/rfc6749/test_request_validator.py index 9dde814..257280c 100644 --- a/tests/oauth2/rfc6749/test_request_validator.py +++ b/tests/oauth2/rfc6749/test_request_validator.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from oauthlib.oauth2 import RequestValidator from ...unittest import TestCase diff --git a/tests/oauth2/rfc6749/test_server.py b/tests/oauth2/rfc6749/test_server.py index 901e461..9288e49 100644 --- a/tests/oauth2/rfc6749/test_server.py +++ b/tests/oauth2/rfc6749/test_server.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/oauth2/rfc6749/test_tokens.py b/tests/oauth2/rfc6749/test_tokens.py index e6f49b1..61a23cb 100644 --- a/tests/oauth2/rfc6749/test_tokens.py +++ b/tests/oauth2/rfc6749/test_tokens.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - import mock from oauthlib.common import Request diff --git a/tests/oauth2/rfc6749/test_utils.py b/tests/oauth2/rfc6749/test_utils.py index 6b85b27..cfc6c2c 100644 --- a/tests/oauth2/rfc6749/test_utils.py +++ b/tests/oauth2/rfc6749/test_utils.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - import datetime import os diff --git a/tests/openid/connect/core/endpoints/test_claims_handling.py b/tests/openid/connect/core/endpoints/test_claims_handling.py index 5f39d96..943210c 100644 --- a/tests/openid/connect/core/endpoints/test_claims_handling.py +++ b/tests/openid/connect/core/endpoints/test_claims_handling.py @@ -6,8 +6,6 @@ The claims parameter is an optional query param for the Authorization Request en request the claims should be transferred (via the oauthlib request) to be persisted with the Access Token when it is created. """ -from __future__ import absolute_import, unicode_literals - import mock from oauthlib.openid import RequestValidator diff --git a/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py b/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py index cb61780..26ff46b 100644 --- a/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py +++ b/tests/openid/connect/core/endpoints/test_openid_connect_params_handling.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - import mock from oauthlib.oauth2 import InvalidRequestError diff --git a/tests/openid/connect/core/endpoints/test_userinfo_endpoint.py b/tests/openid/connect/core/endpoints/test_userinfo_endpoint.py index 4593d79..9edc970 100644 --- a/tests/openid/connect/core/endpoints/test_userinfo_endpoint.py +++ b/tests/openid/connect/core/endpoints/test_userinfo_endpoint.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import mock import json diff --git a/tests/openid/connect/core/grant_types/test_authorization_code.py b/tests/openid/connect/core/grant_types/test_authorization_code.py index bae780b..b6bb99c 100644 --- a/tests/openid/connect/core/grant_types/test_authorization_code.py +++ b/tests/openid/connect/core/grant_types/test_authorization_code.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/openid/connect/core/grant_types/test_dispatchers.py b/tests/openid/connect/core/grant_types/test_dispatchers.py index 53625b2..2fc4ae6 100644 --- a/tests/openid/connect/core/grant_types/test_dispatchers.py +++ b/tests/openid/connect/core/grant_types/test_dispatchers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals import mock from oauthlib.common import Request diff --git a/tests/openid/connect/core/grant_types/test_hybrid.py b/tests/openid/connect/core/grant_types/test_hybrid.py index 66dfa85..3347031 100644 --- a/tests/openid/connect/core/grant_types/test_hybrid.py +++ b/tests/openid/connect/core/grant_types/test_hybrid.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import mock from oauthlib.oauth2.rfc6749 import errors diff --git a/tests/openid/connect/core/grant_types/test_implicit.py b/tests/openid/connect/core/grant_types/test_implicit.py index 0d04e6e..c8fefd4 100644 --- a/tests/openid/connect/core/grant_types/test_implicit.py +++ b/tests/openid/connect/core/grant_types/test_implicit.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import mock from oauthlib.common import Request diff --git a/tests/openid/connect/core/test_request_validator.py b/tests/openid/connect/core/test_request_validator.py index ebe0aeb..6a800d4 100644 --- a/tests/openid/connect/core/test_request_validator.py +++ b/tests/openid/connect/core/test_request_validator.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - from oauthlib.openid import RequestValidator from tests.unittest import TestCase diff --git a/tests/openid/connect/core/test_server.py b/tests/openid/connect/core/test_server.py index 33424b4..681748f 100644 --- a/tests/openid/connect/core/test_server.py +++ b/tests/openid/connect/core/test_server.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import json import mock diff --git a/tests/openid/connect/core/test_tokens.py b/tests/openid/connect/core/test_tokens.py index fde89d6..f1a6688 100644 --- a/tests/openid/connect/core/test_tokens.py +++ b/tests/openid/connect/core/test_tokens.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - import mock from oauthlib.openid.connect.core.tokens import JWTToken diff --git a/tests/test_common.py b/tests/test_common.py index 5acd8e7..b0fb4b0 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - import os import sys -- cgit v1.2.1