From b38c9ca4be55d6dbd2c48cb83e69e8bb847a5704 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:37:49 +0300 Subject: [PATCH 1/6] Remove unused mock backport --- requirements-test.txt | 1 - setup.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index 97c16d7..ac26fb1 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,5 +1,4 @@ -r requirements.txt coveralls==3.3.1 -mock==4.0.3 requests-mock==1.11.0 selenium==4.18.1 diff --git a/setup.py b/setup.py index dea8fd7..6945adf 100644 --- a/setup.py +++ b/setup.py @@ -64,6 +64,6 @@ def readall(path): "Programming Language :: Python :: Implementation :: PyPy", ], zip_safe=False, - tests_require=['mock;python_version<"3.3"', "requests-mock"], + tests_require=["requests-mock"], test_suite="tests", ) From 421c8e25cb1a6480004a49f4232b0aca390d9e8e Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:39:39 +0300 Subject: [PATCH 2/6] TEMP CI --- .github/workflows/run-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 0c055b8..ca76ffd 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,7 +1,6 @@ name: Run Tests on: push: - branches: [ master ] pull_request: branches: [ master ] jobs: From 9c15fe0f7b444de5d7945b658cb589416a3b72f4 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:40:24 +0300 Subject: [PATCH 3/6] Universal wheels only needed for Python 2 support --- setup.cfg | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index ed8a958..0c9e0fc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,2 @@ -[bdist_wheel] -universal = 1 - [metadata] license_file = LICENSE From d891f78da0ad6722434e6de7edbe3f085725d869 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:41:45 +0300 Subject: [PATCH 4/6] Add support for Python 3.13 --- .github/workflows/run-tests.yml | 2 ++ setup.py | 1 + tox.ini | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ca76ffd..4812225 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,6 +20,8 @@ jobs: tox-env: py311 - python-version: "3.12" tox-env: py312 + - python-version: "3.13" + tox-env: py313 - python-version: "pypy3.10" tox-env: pypy310 steps: diff --git a/setup.py b/setup.py index 6945adf..9048198 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,7 @@ def readall(path): "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ], diff --git a/tox.ini b/tox.ini index 393d5c6..8d64456 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py{38,39,310,311,312,py310},docs,readme,ruff +envlist=py{38,39,310,311,312,313,py310},docs,readme,ruff [testenv] description=run test on {basepython} From 74e0fc62b9a66216ae1a7b5e424a242b253228e6 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:43:20 +0300 Subject: [PATCH 5/6] Drop support for EOL Python 3.7 --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 9048198..d955f84 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ def readall(path): author_email="me@kennethreitz.com", url="https://github.com/requests/requests-oauthlib", packages=["requests_oauthlib", "requests_oauthlib.compliance_fixes"], - python_requires=">=3.7", + python_requires=">=3.8", install_requires=["oauthlib>=3.0.0", "requests>=2.0.0"], extras_require={"rsa": ["oauthlib[signedtoken]>=3.0.0"]}, license="ISC", @@ -54,7 +54,6 @@ def readall(path): "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", From e9003cffa5e1dd3a35317a499120dbbcfd9889b1 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:45:12 +0300 Subject: [PATCH 6/6] Upgrade syntax with pyupgrade --py38-plus --- docs/conf.py | 2 -- requests_oauthlib/oauth1_auth.py | 1 - requests_oauthlib/oauth1_session.py | 8 ++++---- requests_oauthlib/oauth2_session.py | 8 ++++---- setup.py | 4 +--- tests/examples/base.py | 6 +++--- tests/test_core.py | 1 - tests/test_oauth2_session.py | 6 +++--- 8 files changed, 15 insertions(+), 21 deletions(-) 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