Skip to content

Commit 306f78f

Browse files
committed
Enforce f-string interpolation with Ruff
- Adds a pre-commit hook for ungoing enforcement. - --force-exclude prevents generated migrations from causing problems.
1 parent 8d202f9 commit 306f78f

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ These can be installed be appending `--extra <optional dependency>` like so:
6868
uv sync --extra cli --extra docs --extra subscription
6969
```
7070

71+
## Python linting
72+
73+
Ruff is the source of truth for Python linting. Read `pyproject.toml` and `pulumi/ruff.toml` for the active rules.
74+
7175
## Re-bootstrapping the project
7276

7377
If you find your environment in a troubled state (it happens) you can add the option `--from-scratch` to bootstrap like

pulumi/ruff.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ quote-style = "single"
2020

2121
[lint]
2222
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
23-
select = ["E", "F"]
23+
# Require f-strings for interpolation instead of printf-style formatting (UP031)
24+
# or `.format` calls (UP032).
25+
select = ["E", "F", "UP031", "UP032"]
2426
ignore = []
2527

2628
# Allow autofix for all enabled rules (when `--fix`) is provided.

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ quote-style = "single"
131131
[tool.ruff.lint]
132132
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
133133
# Enable flagging print (T201)
134-
select = ["E", "F", "T201"]
134+
# Require f-strings for interpolation instead of printf-style formatting (UP031)
135+
# or `.format` calls (UP032).
136+
select = ["E", "F", "T201", "UP031", "UP032"]
135137
ignore = []
136138

137139
# Allow autofix for all enabled rules (when `--fix`) is provided.

src/thunderbird_accounts/authentication/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def _prepare_reauthorization(self, request):
441441
request.session['oidc_login_next'] = request.get_full_path()
442442

443443
query = urlencode(params, quote_via=quote)
444-
return '{auth_url}?{query}'.format(auth_url=auth_url, query=query)
444+
return f'{auth_url}?{query}'
445445

446446

447447
class SetHostIPInAllowedHostsMiddleware:

0 commit comments

Comments
 (0)