Chore: Pin ruff rule selection - #175
Merged
ModeSevenIndustrialSolutions merged 1 commit intoJul 30, 2026
Merged
Conversation
This repository runs the ruff hook with no ruff configuration, so it
applies whatever ruff's default rule set happens to be. That default
is not stable across releases: 59 rules across 2 categories in 0.15.22,
413 across 38 in 0.16.0. A routine pre-commit autoupdate crossing that
boundary changes which rules run, on code nobody has touched. That is
what currently fails the open autoupdate pull request here, on six
findings: RUF100, I001, PIE810, PLW1510 and SIM102.
The selection is deliberately narrow. It is the widest set this
repository already satisfies, so pinning changes no behaviour today and
both ruff 0.15.22 and 0.16.0 report all checks passing.
It falls short of the organisation superset by "I" and "B", and both
gaps are code changes rather than configuration ones:
- "B" adds one B904 raise-without-from site in
src/resolve_config_source.py, needing a judgement about which
exception context to preserve.
- "I" flags the test module import block, which deliberately calls
sys.path.insert() before importing the module under test. That
file is mirrored byte-for-byte with harden-runner-block-action and
carries a "DO NOT EDIT IN ISOLATION" banner requiring paired pull
requests, so it cannot be resolved from this repository alone.
Folding either into a configuration chore would obscure both.
The test per-file-ignores list rules that are not selected yet, so that
widening the selection later does not immediately flag every test
module. PLR0917 is there because tests stacking @patch decorators
cannot satisfy it: unittest.mock injects each mock positionally, so a
keyword-only signature is impossible rather than merely inconvenient.
Co-authored-by: Claude <claude@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Copilot started reviewing on behalf of
ModeSevenIndustrialSolutions
July 30, 2026 13:30
View session
There was a problem hiding this comment.
Pull request overview
This PR introduces an explicit Ruff configuration to stabilize lint behavior across Ruff upgrades (notably the default-rule expansion between ruff 0.15.x and 0.16.x) and prevent unrelated pre-commit autoupdate runs from changing which lint rules apply.
Changes:
- Adds a new
.ruff.tomlthat pins lint rule selection to["E", "W", "F", "C4", "UP"]. - Keeps existing behavior stable by explicitly ignoring
E501and documenting the rationale for future widening vialint.per-file-ignoresfor tests.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
askb
approved these changes
Jul 30, 2026
ModeSevenIndustrialSolutions
merged commit Jul 30, 2026
2892883
into
lfreleng-actions:main
11 checks passed
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
.ruff.toml:50
B008is listed under[lint].ignore, butBrules are not enabled inselect, so this ignore is currently redundant and can be confusing to maintainers. Since it has no effect today, consider removing it (it can be re-added when/ifBis enabled).
ignore = [
"E501", # line-too-long: the formatter owns line length
"B008", # function call in argument default: typer/click idiom
]
.ruff.toml:62
- There appears to be an extra blank line at the end of the file that contains whitespace. This can trip whitespace-cleanup hooks (e.g.,
trailing-whitespace) and cause pre-commit failures.
"tests/**/*.py" = ["S101", "ARG", "PLR0913", "PLR0917", "PLR2004"]
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.
Why
This repository runs the ruff hook with no ruff configuration, so it applies whatever ruff's default rule set happens to be. That default is not stable across releases:
A routine
pre-commit autoupdatecrossing that boundary changes which rules run on code nobody has touched. That is exactly what fails the open autoupdate PR #173 here, on six findings:RUF100tests/test_resolve_config_source.pyI001tests/test_resolve_config_source.pySIM102src/resolve_config_source.pyPIE810src/resolve_config_source.pyPLW1510src/resolve_config_source.pyDeliberately narrow
select = ["E", "W", "F", "C4", "UP"]is the widest set this repository already satisfies, so pinning changes no behaviour today.It falls short of the organisation superset (
E, W, F, I, B, C4, UP) byIandB. I checked both, and each is a code change rather than a configuration one:Badds oneB904raise-without-from site atsrc/resolve_config_source.py:314, which needs a judgement about which exception context to preserve.Iflags the import block intests/test_resolve_config_source.py, which deliberately callssys.path.insert()before importing the module under test. The autofix is only a blank-line removal, but that file is mirrored byte-for-byte withharden-runner-block-actionand carries an explicit banner:So it cannot be resolved from this repository alone, and I have deliberately not touched it.
Folding either into a configuration chore would obscure both.
A nice side effect of selecting
E: the existing# noqa: E402on line 30 becomes meaningful again. It is currently unused (hence the twoRUF100findings), becauseE402is not enabled under ruff's default.Note on category-level pinning
Ruff selectors are prefixes, so a future release adding new
E*orF*rules will still enable them here. Pinning every rule code individually would be exhaustive and unmaintainable; the aim is to bound the blast radius — 38 categories back to five — not to freeze the set outright.line-lengthandtarget-versionare left unset on purpose. Both would change existing behaviour rather than pin it (target-versionalters whichpyupgraderules fire).Validation
ruff 0.16.0 check src tests→ All checks passed!ruff 0.15.22 check src tests→ All checks passed! (so this is not a one-way door)pre-commit run --all-files→ every hook passes, includingreuse linton the new fileUnblocks #173.
Related
Paired with the identical change in
harden-runner-block-action, which shares the sameresolve_config_sourcemodule and test file.