ci: lint the whole repo, and pin the rule set so it stays deterministic
Widens the lint step from `ruff check app/` to `ruff check .`, since tests/ and
scripts/ had drifted to 11 findings while unchecked (fixed in 1c6ccce).
Widening alone would have been unsafe, and the check turned up something worse
than the drift: CI installs ruff unpinned, the repo had no [tool.ruff] config,
and ruff's default rule set is not stable across releases. Local 0.15.4 reports
0 findings in app/; 0.16.2 -- what `pip install ruff` resolves to today --
reports 376. 168 of those are B008 flagging FastAPI's `Depends()` in a signature
default, which is the framework's documented idiom, not a defect. So the lint
job would have failed the deploy pipeline on untouched code at the next push,
independent of this change.
Pinning the ruff version would freeze the bug in place. Pinning the *rule set*
is the actual fix: select = ["E4", "E7", "E9", "F"] in pyproject.toml, the set
the tree was already clean under, now enforced repo-wide. The ruff version can
float freely without changing what CI enforces.
Verified both scopes against both versions with caches disabled: `ruff check .`
passes under 0.15.4 and 0.16.2. Confirmed the pin actually binds rather than
passing by luck -- a probe file using `Depends()` in a default is clean under
the committed config and reports B008 + I001 under `--isolated` 0.16.2 defaults.
Full suite still 852 passed, 1 skipped.
Adding rules is welcome; do it in pyproject.toml with the fixes in the same
commit.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,7 +38,10 @@ jobs:
|
|||||||
python-version: "3.12"
|
python-version: "3.12"
|
||||||
cache: "pip"
|
cache: "pip"
|
||||||
- run: pip install ruff
|
- run: pip install ruff
|
||||||
- run: ruff check app/
|
# Whole repo, not just app/: tests/ and scripts/ drifted to 11 findings
|
||||||
|
# while unchecked. Rules are pinned in pyproject.toml, so the unpinned
|
||||||
|
# ruff above cannot change what this enforces.
|
||||||
|
- run: ruff check .
|
||||||
|
|
||||||
test:
|
test:
|
||||||
needs: lint
|
needs: lint
|
||||||
|
|||||||
@@ -40,3 +40,21 @@ include = ["app*"]
|
|||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
asyncio_mode = "auto"
|
asyncio_mode = "auto"
|
||||||
testpaths = ["tests"]
|
testpaths = ["tests"]
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
target-version = "py312"
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
# Pinned explicitly rather than inherited. CI installs ruff unpinned, and the
|
||||||
|
# default rule set is not stable across releases: 0.16 broadened it so far that
|
||||||
|
# `ruff check app/` went from 0 findings to 376 -- 168 of them B008 flagging
|
||||||
|
# FastAPI's `Depends()` in a signature default, which is the framework's
|
||||||
|
# documented idiom and not a defect. An unpinned linter with drifting defaults
|
||||||
|
# fails the deploy pipeline on code nobody touched, so the rule set is the thing
|
||||||
|
# to pin; the ruff version can then float freely.
|
||||||
|
#
|
||||||
|
# E4 imports, E7 statements, E9 syntax/IO errors, F pyflakes. This is the set the
|
||||||
|
# tree was already clean under, now applied repo-wide instead of to app/ alone.
|
||||||
|
# Adding rules is welcome -- do it here, deliberately, with the fixes in the same
|
||||||
|
# commit.
|
||||||
|
select = ["E4", "E7", "E9", "F"]
|
||||||
|
|||||||
Reference in New Issue
Block a user