diff --git a/docs/conf.py b/docs/conf.py index 6830620..a9956a1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # Requests-OAuthlib documentation build configuration file, created by # sphinx-quickstart on Fri May 10 11:49:01 2013. # diff --git a/requests_oauthlib/oauth1_auth.py b/requests_oauthlib/oauth1_auth.py index f8c0bd6..6d3dcfb 100644 --- a/requests_oauthlib/oauth1_auth.py +++ b/requests_oauthlib/oauth1_auth.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import logging from oauthlib.common import extract_params diff --git a/requests_oauthlib/oauth1_session.py b/requests_oauthlib/oauth1_session.py index 7625c80..f55b03c 100644 --- a/requests_oauthlib/oauth1_session.py +++ b/requests_oauthlib/oauth1_session.py @@ -25,7 +25,7 @@ def urldecode(body): class TokenRequestDenied(ValueError): def __init__(self, message, response): - super(TokenRequestDenied, self).__init__(message) + super().__init__(message) self.response = response @property @@ -36,7 +36,7 @@ def status_code(self): class TokenMissing(ValueError): def __init__(self, message, response): - super(TokenMissing, self).__init__(message) + super().__init__(message) self.response = response @@ -149,7 +149,7 @@ def __init__( signature creation. :param **kwargs: Additional keyword arguments passed to `OAuth1` """ - super(OAuth1Session, self).__init__() + super().__init__() self._client = OAuth1( client_key, client_secret=client_secret, @@ -348,7 +348,7 @@ def _populate_attributes(self, token): self._client.client.resource_owner_key = token["oauth_token"] else: raise TokenMissing( - "Response does not contain a token: {resp}".format(resp=token), token + f"Response does not contain a token: {token}", token ) if "oauth_token_secret" in token: self._client.client.resource_owner_secret = token["oauth_token_secret"] diff --git a/requests_oauthlib/oauth2_session.py b/requests_oauthlib/oauth2_session.py index 93cc4d7..ac764ac 100644 --- a/requests_oauthlib/oauth2_session.py +++ b/requests_oauthlib/oauth2_session.py @@ -11,7 +11,7 @@ class TokenUpdated(Warning): def __init__(self, token): - super(TokenUpdated, self).__init__() + super().__init__() self.token = token @@ -74,7 +74,7 @@ def __init__( :param pkce: Set "S256" or "plain" to enable PKCE. Default is disabled. :param kwargs: Arguments to pass to the Session constructor. """ - super(OAuth2Session, self).__init__(**kwargs) + super().__init__(**kwargs) self._client = client or WebApplicationClient(client_id, token=token) self.token = token or {} self._scope = scope @@ -87,7 +87,7 @@ def __init__( self._pkce = pkce if self._pkce not in ["S256", "plain", None]: - raise AttributeError("Wrong value for {}(.., pkce={})".format(self.__class__, self._pkce)) + raise AttributeError(f"Wrong value for {self.__class__}(.., pkce={self._pkce})") # Ensure that requests doesn't do any automatic auth. See #278. # The default behavior can be re-enabled by setting auth to None. @@ -563,7 +563,7 @@ def request( log.debug("Requesting url %s using method %s.", url, method) log.debug("Supplying headers %s and data %s", headers, data) log.debug("Passing through key word arguments %s.", kwargs) - return super(OAuth2Session, self).request( + return super().request( method, url, headers=headers, data=data, files=files, **kwargs ) diff --git a/setup.py b/setup.py index d955f84..2b189f4 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- - import os import sys import re @@ -10,7 +8,7 @@ # Get the version version_regex = r'__version__ = ["\']([^"\']*)["\']' -with open("requests_oauthlib/__init__.py", "r") as f: +with open("requests_oauthlib/__init__.py") as f: text = f.read() match = re.search(version_regex, text) diff --git a/tests/examples/base.py b/tests/examples/base.py index 562cead..ba80dc7 100644 --- a/tests/examples/base.py +++ b/tests/examples/base.py @@ -27,8 +27,8 @@ def tearDown(self): self.proc.kill() def replaceVariables(self, filein ,fileout, vars): - with open(filein, "rt") as fin: - with open(fileout, "wt") as fout: + with open(filein) as fin: + with open(fileout, "w") as fout: for line in fin: for k, v in vars.items(): line = line.replace(k, v) @@ -44,7 +44,7 @@ def run_sample(self, filepath, variables): :type variables: dict """ inpath = os.path.join(cwd, "..", "..", "docs", "examples", filepath) - outpath = os.path.join(cwd, "tmp_{}".format(filepath)) + outpath = os.path.join(cwd, f"tmp_{filepath}") self.replaceVariables(inpath, outpath, variables) self.proc = subprocess.Popen( diff --git a/tests/test_core.py b/tests/test_core.py index 7ae5d08..21920a8 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import requests import requests_oauthlib import oauthlib diff --git a/tests/test_oauth2_session.py b/tests/test_oauth2_session.py index 7e3e63c..5db6435 100644 --- a/tests/test_oauth2_session.py +++ b/tests/test_oauth2_session.py @@ -63,7 +63,7 @@ def test_add_token(self): token = "Bearer " + self.token["access_token"] def verifier(r, **kwargs): - auth_header = r.headers.get(str("Authorization"), None) + auth_header = r.headers.get("Authorization", None) self.assertEqual(auth_header, token) resp = mock.MagicMock() resp.cookes = [] @@ -544,10 +544,10 @@ def setUp(self): with open(netrc_loc, "w") as f: f.write("machine i.b\n" " password abc123\n" " login spam@eggs.co\n") - super(OAuth2SessionNetrcTest, self).setUp() + super().setUp() def tearDown(self): - super(OAuth2SessionNetrcTest, self).tearDown() + super().tearDown() if self.prehome is not None: os.environ["HOME"] = self.prehome