fix(QUAL-008): pin the pre-commit ruff hook to the version CI installs - #117
Open
DoRmAmMu1997 wants to merge 2 commits into
Open
fix(QUAL-008): pin the pre-commit ruff hook to the version CI installs#117DoRmAmMu1997 wants to merge 2 commits into
DoRmAmMu1997 wants to merge 2 commits into
Conversation
`.pre-commit-config.yaml` pinned `ruff-pre-commit` at v0.15.1 while `constraints.txt` pinned `ruff==0.16.3`. The config file asked for these to stay aligned in a comment on the line above the rev, but nothing enforced it, so they drifted a full minor version apart. A commit-time hook that lints with different rules than CI can pass code CI then rejects, which defeats the purpose of having the hook. `tests/test_supply_chain_policy.py` was the natural place to catch this - it already asserts the exact CI command strings and the `constraints.txt` pin list - but it only checked the hook's ids, file regex and no-`--fix` policy, and separately that a `ruff==` pin exists. It never compared the two values. Bump the hook to v0.16.3 and add the missing guard: parse the ruff-pre-commit rev, parse the `ruff==` pin, and require equality, with a companion test proving the guard fails on a drifted rev. Verified by re-drifting the rev to v0.15.1 and watching the assertion fail with `- 0.16.3 / + 0.15.1`. `python -m ruff check` over the full gated path set passes under 0.16.3, so the bump surfaces no new findings. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The drift
.pre-commit-config.yamlpinnedruff-pre-commitat v0.15.1 whileconstraints.txtpinnedruff==0.16.3— a full minor version apart, with real rule differences.The config file asked for these to stay aligned, in a comment on the line directly above the rev:
Nothing enforced it, so it drifted. A commit-time hook that lints with different rules than CI can pass code CI then rejects — which defeats the purpose of having the hook at all.
Why the existing guard missed it
tests/test_supply_chain_policy.pyis exactly the right place for this — it already asserts the verbatim CI command strings and theconstraints.txtpin list. But it checked:filesregex, and the no---fixpolicy (:145)ruff==pin exists inconstraints.txt(:191)...and never compared the two values. The one cross-file invariant the config explicitly asked for was the one nobody guarded.
The fix
v0.16.3(tag confirmed upstream at65dbdb5).test_pre_commit_ruff_rev_matches_the_constraints_pin: parses theruff-pre-commitrev, parses theruff==pin, requires equality.test_pre_commit_ruff_rev_guard_rejects_a_drifted_pin, matching the file's existing pattern of proving each guard actually bites (same shape as the QUAL-007ignore_errorspair).Verification
v0.15.1and confirmed the new assertion fails with- 0.16.3/+ 0.15.1, then restored it.python -m ruff check app.py backend screeners ui Dependencies testspasses under 0.16.3, so the bump surfaces no new findings.pytest -q --cov=... --cov-fail-under=89— 2036 passed, 1 skipped, 89.96%pre_commit validate-config(the command CI runs) passes.git diff origin/main HEAD -- constraints.txt pyproject.toml— empty.origin/mainmerged in and gates re-run after PRs fix(DATA-003): stop the scan re-dirtying the candle cache it just repaired #112/fix(DATA-004): stop re-downloading stocks that listed after the window opened #114 landed.Note:
pre-commit run --all-filescannot execute on the development machine — it fails to clone its hook environments (InvalidManifestError) on untouchedmaintoo, so it is a pre-existing local environment issue rather than anything this PR introduces. CI runs onlyvalidate-config, which passes. Lint was verified directly withpython -m ruff check, which is what the hook shells out to anyway.🤖 Generated with Claude Code