Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.13 and drop EOL 3.7 #553

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Run Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
Expand All @@ -21,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:
Expand Down
2 changes: 0 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down
1 change: 0 additions & 1 deletion requests_oauthlib/oauth1_auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import logging

from oauthlib.common import extract_params
Expand Down
8 changes: 4 additions & 4 deletions requests_oauthlib/oauth1_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"]
Expand Down
8 changes: 4 additions & 4 deletions requests_oauthlib/oauth2_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class TokenUpdated(Warning):
def __init__(self, token):
super(TokenUpdated, self).__init__()
super().__init__()
self.token = token


Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
)

Expand Down
1 change: 0 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
-r requirements.txt
coveralls==3.3.1
mock==4.0.3
requests-mock==1.11.0
selenium==4.18.1
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[bdist_wheel]
universal = 1

[metadata]
license_file = LICENSE
10 changes: 4 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import re
Expand All @@ -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)

Expand Down Expand Up @@ -43,7 +41,7 @@ def readall(path):
author_email="[email protected]",
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",
Expand All @@ -54,16 +52,16 @@ 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",
"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",
],
zip_safe=False,
tests_require=['mock;python_version<"3.3"', "requests-mock"],
tests_require=["requests-mock"],
test_suite="tests",
)
6 changes: 3 additions & 3 deletions tests/examples/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down
1 change: 0 additions & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import requests
import requests_oauthlib
import oauthlib
Expand Down
6 changes: 3 additions & 3 deletions tests/test_oauth2_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -544,10 +544,10 @@ def setUp(self):
with open(netrc_loc, "w") as f:
f.write("machine i.b\n" " password abc123\n" " login [email protected]\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
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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}
Expand Down
Loading