Skip to content

Commit 31a6550

Browse files
committed
chore: modernize pre-commit
1 parent f7be5d0 commit 31a6550

8 files changed

+64
-40
lines changed

.pre-commit-config.yaml

+8-20
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,24 @@
11
---
22
repos:
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: 'v0.4.1'
4+
rev: 'v0.9.3'
55
hooks:
66
- id: ruff
77
args: [--fix, --exit-non-zero-on-fix]
88
- id: ruff-format
99
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: v4.6.0
10+
rev: v5.0.0
1111
hooks:
1212
- id: fix-byte-order-marker
1313
- id: trailing-whitespace
1414
exclude: "\\.svg$|\\.map$|\\.min\\.css$|\\.min\\.js$|\\.po$|\\.pot$"
1515
- id: end-of-file-fixer
1616
exclude: "\\.svg$|\\.map$|\\.min\\.css$|\\.min\\.js$|\\.po$|\\.pot$"
1717
- id: check-toml
18-
- repo: https://github.com/pycqa/isort
19-
rev: "5.13.2"
18+
- repo: https://github.com/codespell-project/codespell
19+
rev: v2.4.0
2020
hooks:
21-
- id: isort
22-
name: isort (python)
23-
args: ["--force-single-line-imports", "--profile", "black"]
24-
- repo: https://github.com/PyCQA/docformatter
25-
rev: v1.7.5
26-
hooks:
27-
- id: docformatter
28-
- repo: https://github.com/asottile/pyupgrade
29-
rev: v3.15.2
30-
hooks:
31-
- id: pyupgrade
32-
args: ["--py39-plus"]
33-
- repo: https://github.com/rtts/djhtml
34-
rev: 3.0.6
35-
hooks:
36-
- id: djhtml
21+
- id: codespell
22+
additional_dependencies:
23+
- tomli
24+
args: [--write-changes]

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Versions follow [Semantic Versioning](https://semver.org/>) (<major>.<minor>.<pa
2020
### Changed
2121

2222
- Configuration is read from `.pytest-iam.env`
23-
- Configuration is read from enviroment vars prefixed by `PYTEST_IAM_`
23+
- Configuration is read from environment vars prefixed by `PYTEST_IAM_`
2424

2525
## [0.0.11] - 2024-04-22
2626

@@ -61,7 +61,7 @@ Versions follow [Semantic Versioning](https://semver.org/>) (<major>.<minor>.<pa
6161

6262
### Fixed
6363

64-
- python <=3.8 uncompatible typing
64+
- python <=3.8 incompatible typing
6565

6666
## [0.0.5] - 2023-12-22
6767

doc/client-applications.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Users & groups
1717
~~~~~~~~~~~~~~
1818

1919
You can use the available :class:`~canaille.core.models.User` and :class:`~canaille.core.models.Group` models to set up their
20-
IAM server for your tests. Optionnally you can put them in pytest fixtures so they are re-usable:
20+
IAM server for your tests. Optionally you can put them in pytest fixtures so they are reusable:
2121

2222

2323
.. code:: python

doc/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
author = "Yaal Coop"
3232

3333
release = metadata.version("pytest_iam")
34-
version = "%s.%s" % tuple(map(int, release.split(".")[:2]))
34+
version = "{}.{}".format(*tuple(map(int, release.split(".")[:2])))
3535
language = "en"
3636
exclude_patterns = []
3737
pygments_style = "sphinx"

doc/resource-servers.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Resource servers
22
================
33

4-
If you are writing a resource server, you will probably want to test if your application can successfully check if a token is valid, to determine wether resources can be accessed.
4+
If you are writing a resource server, you will probably want to test if your application can successfully check if a token is valid, to determine whether resources can be accessed.
55
If the access token is a `RFC9068 <https://www.rfc-editor.org/rfc/rfc9068.html>`_ JWT, then your application will need to check
66
the signature against the identity server JWKs. If the access token is not a JWT then your application will need to perform a
77
request against the identity server token introspection endpoint.

poetry.lock

+15-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+30-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ iam = "pytest_iam"
4343
authlib = "^1.2.1"
4444
pytest-cov = "^6.0.0"
4545
requests = "^2.31.0"
46+
types-requests = "*"
4647

4748
[tool.poetry.group.doc]
4849
optional = true
@@ -53,8 +54,35 @@ shibuya = "^2024.7.13"
5354
sphinx = "^7.0.0"
5455
sphinx-issues = "^4.0.0"
5556

56-
[tool.ruff]
57-
ignore = ["E501", "E722"]
57+
[tool.ruff.lint]
58+
select = [
59+
"B", # flake8-bugbear
60+
"D", # pydocstyle
61+
"E", # pycodestyle
62+
"F", # pyflakes
63+
"I", # isort
64+
"UP", # pyupgrade
65+
]
66+
ignore = [
67+
"E501", # line-too-long
68+
"E722", # bare-except
69+
"D100", # public module
70+
"D101", # public class
71+
"D102", # public method
72+
"D103", # public function
73+
"D104", # public package
74+
"D105", # magic method
75+
"D106", # nested class
76+
"D107", # public init
77+
"D203", # no-blank-line-before-class
78+
"D213", # multi-line-summary-second-line
79+
]
80+
81+
[tool.ruff.lint.isort]
82+
force-single-line = true
83+
84+
[tool.ruff.format]
85+
docstring-code-format = true
5886

5987
[tool.tox]
6088
legacy_tox_ini = """

pytest_iam/__init__.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def url(self) -> str:
5454
return f"http://localhost:{self.port}/"
5555

5656
def random_user(self, **kwargs) -> User:
57-
"""Generates a :class:`~canaille.core.models.User` with random values.
57+
"""Generate a :class:`~canaille.core.models.User` with random values.
5858
5959
Any parameter will be used instead of a random value.
6060
"""
@@ -66,7 +66,7 @@ def random_user(self, **kwargs) -> User:
6666
return user
6767

6868
def random_group(self, **kwargs) -> Group:
69-
"""Generates a :class:`~canaille.core.models.Group` with random values.
69+
"""Generate a :class:`~canaille.core.models.Group` with random values.
7070
7171
Any parameter will be used instead of a random value.
7272
"""
@@ -78,8 +78,7 @@ def random_group(self, **kwargs) -> Group:
7878
return group
7979

8080
def random_token(self, subject, client, **kwargs) -> Token:
81-
"""Generates a test :class:`~canaille.oidc.basemodels.Token` with
82-
random values.
81+
"""Generate a test :class:`~canaille.oidc.basemodels.Token` with random values.
8382
8483
Any parameter will be used instead of a random value.
8584
"""
@@ -103,7 +102,7 @@ def random_token(self, subject, client, **kwargs) -> Token:
103102
return token
104103

105104
def login(self, user):
106-
"""Opens a session for the user in the IAM session.
105+
"""Open a session for the user in the IAM session.
107106
108107
This allows to skip the connection screen.
109108
"""
@@ -114,7 +113,6 @@ def consent(self, user, client=None):
114113
115114
:param client: If :const:`None`, all existing clients are consented.
116115
"""
117-
118116
with self.app.app_context():
119117
clients = [client] if client else self.backend.query(models.Client)
120118

@@ -141,9 +139,7 @@ def consent(self, user, client=None):
141139

142140
@pytest.fixture(scope="session")
143141
def iam_configuration(tmp_path_factory) -> dict[str, Any]:
144-
"""Fixture for editing the configuration of
145-
:meth:`~pytest_iam.iam_server`."""
146-
142+
"""Fixture for editing the configuration of :meth:`~pytest_iam.iam_server`."""
147143
private_key, public_key = generate_keypair()
148144
return {
149145
"TESTING": True,
@@ -185,9 +181,7 @@ def iam_configuration(tmp_path_factory) -> dict[str, Any]:
185181

186182
@pytest.fixture(scope="session")
187183
def iam_server(iam_configuration) -> Server:
188-
"""Fixture that creates a Canaille server listening a random port in a
189-
thread."""
190-
184+
"""Fixture that creates a Canaille server listening a random port in a thread."""
191185
port = portpicker.pick_unused_port()
192186
app = create_app(
193187
config=iam_configuration, env_file=".pytest-iam.env", env_prefix="PYTEST_IAM_"

0 commit comments

Comments
 (0)