Skip to content

Commit 49f0739

Browse files
authored
linting fixes + deps update (#192)
1 parent bff2c7b commit 49f0739

File tree

8 files changed

+392
-395
lines changed

8 files changed

+392
-395
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-merge-conflict
66
- id: check-yaml
@@ -13,14 +13,14 @@ repos:
1313
- id: python-use-type-annotations
1414
- id: text-unicode-replacement-char
1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.11.7
16+
rev: v0.12.12
1717
hooks:
1818
- id: ruff-format
19-
- id: ruff
19+
- id: ruff-check
2020
args: [ --fix ]
2121
- id: ruff-format
2222
- repo: https://github.com/pre-commit/mirrors-mypy
23-
rev: v1.15.0
23+
rev: v1.17.1
2424
hooks:
2525
- id: mypy
2626
args:

poetry.lock

Lines changed: 356 additions & 361 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool]
22
[tool.poetry]
33
name = "requests_oauth2client"
4-
version = "1.7.0"
4+
version = "1.7.1"
55
homepage = "https://github.com/guillp/requests_oauth2client"
66
description = "An OAuth2.x client based on `requests`."
77
authors = ["Guillaume Pujol <guillp.dev@pm.me>"]
@@ -122,7 +122,7 @@ ignore = [
122122
]
123123

124124
[tool.ruff.lint.per-file-ignores]
125-
"tests/**.py" = ["ARG001", "B018", "D100", "D101", "D102", "D103", "D104", "F821", "PGH005", "PLR0913", "PLR0915", "PLR2004", "S101", "S106", "S113",
125+
"tests/**.py" = ["ARG001", "B018", "D100", "D101", "D102", "D103", "D104", "F821", "FBT001", "PGH005", "PLR0913", "PLR0915", "PLR2004", "S101", "S106", "S113",
126126
"PT011", "E501"]
127127

128128
[tool.ruff.lint.pylint]

requests_oauth2client/api_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def request( # noqa: C901, PLR0913, D417
202202
method: str,
203203
path: None | str | bytes | Iterable[str | bytes | int] = None,
204204
*,
205-
params: None | bytes | MutableMapping[str, str] = None,
205+
params: None | bytes | MutableMapping[str, Any] = None,
206206
data: (
207207
Iterable[bytes]
208208
| str
@@ -392,6 +392,7 @@ def to_absolute_url(self, path: None | str | bytes | Iterable[str | bytes | int]
392392
def get(
393393
self,
394394
path: None | str | bytes | Iterable[str | bytes | int] = None,
395+
*,
395396
raise_for_status: bool | None = None,
396397
**kwargs: Any,
397398
) -> requests.Response:
@@ -417,6 +418,7 @@ def get(
417418
def post(
418419
self,
419420
path: str | bytes | Iterable[str | bytes] | None = None,
421+
*,
420422
raise_for_status: bool | None = None,
421423
**kwargs: Any,
422424
) -> requests.Response:
@@ -442,6 +444,7 @@ def post(
442444
def patch(
443445
self,
444446
path: str | bytes | Iterable[str | bytes] | None = None,
447+
*,
445448
raise_for_status: bool | None = None,
446449
**kwargs: Any,
447450
) -> requests.Response:
@@ -467,6 +470,7 @@ def patch(
467470
def put(
468471
self,
469472
path: str | bytes | Iterable[str | bytes] | None = None,
473+
*,
470474
raise_for_status: bool | None = None,
471475
**kwargs: Any,
472476
) -> requests.Response:
@@ -492,6 +496,7 @@ def put(
492496
def delete(
493497
self,
494498
path: str | bytes | Iterable[str | bytes] | None = None,
499+
*,
495500
raise_for_status: bool | None = None,
496501
**kwargs: Any,
497502
) -> requests.Response:

requests_oauth2client/auth.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from attrs import define, field, setters
99
from typing_extensions import override
1010

11+
from .device_authorization import DeviceAuthorizationPollingJob
1112
from .tokens import BearerToken
1213

1314
if TYPE_CHECKING:
@@ -364,8 +365,6 @@ def exchange_device_code_for_token(self) -> None:
364365
This will poll the Token Endpoint until the user finishes the authorization process.
365366
366367
"""
367-
from .device_authorization import DeviceAuthorizationPollingJob
368-
369368
if self.device_code: # pragma: no branch
370369
polling_job = DeviceAuthorizationPollingJob(
371370
client=self.client,

requests_oauth2client/flask/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def token(self, token: BearerToken | str | None) -> None:
6464
session.pop(self.session_key, None)
6565

6666

67-
class FlaskOAuth2ClientCredentialsAuth(FlaskSessionAuthMixin, OAuth2ClientCredentialsAuth): # type: ignore[misc]
67+
class FlaskOAuth2ClientCredentialsAuth(FlaskSessionAuthMixin, OAuth2ClientCredentialsAuth):
6868
"""A `requests` Auth handler for CC grant that stores its token in Flask session.
6969
7070
It will automatically get Access Tokens from an OAuth 2.x AS with the Client Credentials grant

tests/test_deprecated_metaclass.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# ruff: noqa: PGH003,ANN001,ANN002,ANN003,ANN201,ANN202,ANN204,D101
1+
# ruff: noqa: PGH003, ANN201
22
# type: ignore
33
"""Test the metaclass used to deprecated things.
44
55
https://stackoverflow.com/a/52087847 by
66
Kentzo https://stackoverflow.com/users/188530/kentzo
77
"""
88

9+
import pytest
10+
911
from requests_oauth2client.deprecated import _DeprecatedClassMeta
1012

1113

@@ -21,8 +23,10 @@ class DeprecatedClass(metaclass=_DeprecatedClassMeta):
2123
_DeprecatedClassMeta__alias = NewClass
2224

2325

24-
class DeprecatedClassSubclass(DeprecatedClass):
25-
foo = 2
26+
with pytest.warns(DeprecationWarning, match="renamed"):
27+
28+
class DeprecatedClassSubclass(DeprecatedClass):
29+
foo = 2
2630

2731

2832
class DeprecatedClassSubSubclass(DeprecatedClassSubclass):
@@ -39,7 +43,8 @@ def test_deprecating_metaclass():
3943
assert issubclass(DeprecatedClassSubclass, NewClass)
4044
assert issubclass(DeprecatedClassSubSubclass, NewClass)
4145

42-
assert isinstance(DeprecatedClass(), DeprecatedClass)
46+
with pytest.warns(DeprecationWarning, match="renamed"):
47+
assert isinstance(DeprecatedClass(), DeprecatedClass)
4348
assert isinstance(DeprecatedClassSubclass(), DeprecatedClass)
4449
assert isinstance(DeprecatedClassSubSubclass(), DeprecatedClass)
4550
assert isinstance(NewClass(), DeprecatedClass)
@@ -49,6 +54,7 @@ def test_deprecating_metaclass():
4954
assert isinstance(DeprecatedClassSubSubclass(), NewClass)
5055

5156
assert NewClass().foo == 1
52-
assert DeprecatedClass().foo == 1
57+
with pytest.warns(DeprecationWarning, match="renamed"):
58+
assert DeprecatedClass().foo == 1
5359
assert DeprecatedClassSubclass().foo == 2
5460
assert DeprecatedClassSubSubclass().foo == 3

tests/unit_tests/test_flask.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,26 @@ def test_flask(
1818
scope: str,
1919
target_api: str,
2020
) -> None:
21-
try:
22-
from flask import Flask, request
23-
24-
from requests_oauth2client.flask import FlaskOAuth2ClientCredentialsAuth
25-
except ImportError:
26-
pytest.skip("Flask is not available")
21+
flask = pytest.importorskip("flask")
22+
rof = pytest.importorskip("requests_oauth2client.flask")
2723

2824
oauth_client = OAuth2Client(token_endpoint, ClientSecretPost(client_id, client_secret))
29-
auth = FlaskOAuth2ClientCredentialsAuth(
25+
auth = rof.FlaskOAuth2ClientCredentialsAuth(
3026
session_key=session_key,
3127
scope=scope,
3228
client=oauth_client,
3329
)
3430
api_client = ApiClient(target_api, auth=auth)
3531

36-
assert isinstance(api_client.auth, FlaskOAuth2ClientCredentialsAuth)
32+
assert isinstance(api_client.auth, rof.FlaskOAuth2ClientCredentialsAuth)
3733

38-
app = Flask("testapp")
34+
app = flask.Flask("testapp")
3935
app.config["TESTING"] = True
4036
app.config["SECRET_KEY"] = "thisissecret"
4137

42-
@app.route("/api")
38+
@app.route("/api") # type: ignore[misc]
4339
def get() -> Any:
44-
return api_client.get(params=request.args).json()
40+
return api_client.get(params=flask.request.args).json()
4541

4642
access_token = "access_token"
4743
json_resp = {"status": "success"}
@@ -102,19 +98,15 @@ def get() -> Any:
10298

10399

104100
def test_flask_token_kwarg() -> None:
105-
try:
106-
from flask import Flask
107-
108-
from requests_oauth2client.flask import FlaskOAuth2ClientCredentialsAuth
109-
except ImportError:
110-
pytest.skip("Flask is not available")
101+
flask = pytest.importorskip("flask")
102+
rof = pytest.importorskip("requests_oauth2client.flask")
111103

112-
app = Flask("testapp")
104+
app = flask.Flask("testapp")
113105
app.config["TESTING"] = True
114106
app.config["SECRET_KEY"] = "thisissecret"
115107

116108
with app.test_request_context("/"):
117-
auth = FlaskOAuth2ClientCredentialsAuth(
109+
auth = rof.FlaskOAuth2ClientCredentialsAuth(
118110
client=None,
119111
session_key=session_key,
120112
token="xyz",

0 commit comments

Comments
 (0)