Skip to content

Commit 83eb899

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 83eb899

5 files changed

Lines changed: 28 additions & 3 deletions

File tree

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: ruff-check
5+
name: ruff check
6+
entry: uv run ruff check --fix --force-exclude
7+
language: system
8+
types_or: [python, pyi]

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ 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
74+
rules; local pre-commit hooks and CI run Ruff against those configs.
75+
76+
To install and run the local pre-commit hook:
77+
78+
```bash
79+
uv tool install pre-commit
80+
pre-commit install
81+
pre-commit run --all-files
82+
```
83+
7184
## Re-bootstrapping the project
7285

7386
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)