Use ruff select instead of extend-select to keep the rule set explicit - #6964
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Member
Author
|
Merging this PR as a fix of the CI to make it more solid. |
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.
This PR makes TRL's ruff lint rule set explicit and independent of ruff's own default rule selection.
Motivation
Ruff 0.16 raised its default rule selection from 59 to 413 rules.
extend-selectadds onto those defaults, so TRL silently inherits every rule ruff enables by default, including whole families the project never opted into (BLE,SIM,S,TRY,LOG,DTZ,PL*,PIE,FURB,RUF,PYI, ...).This has two consequences today:
--fix. This is why Bump https://github.com/astral-sh/ruff-pre-commit from v0.13.3 to 0.16.4 #6957 is red.Solution
Use
select, which replaces the default selection instead of extending it. The listed rule families stay exactly as they are, so the set of rules TRL enforces becomes a project decision rather than a function of the installed ruff version. Adopting any of the newly defaulted rules remains a separate, deliberate change.At the pinned ruff 0.13.3 this is a no-op: both configurations resolve to byte-identical sets of 170 enabled rules, and
ruff checkon all tracked Python files reportsAll checks passed!before and after. It also passes under ruff 0.16.4 with this change applied.Changes
extend-selectwithselectin the ruff lint configurationNote
Low Risk
Config-only change to lint tooling; no runtime or application logic is affected.
Overview
Ruff linting is pinned to an explicit rule list so newer Ruff releases cannot silently turn on hundreds of extra default rules.
In
pyproject.toml,[tool.ruff.lint]now usesselect(replacingextend-select) with the same families (E,F,I,W,UP,B,T,C). A short comment documents that this avoids inheriting Ruff 0.16+’s expanded defaults. Behavior at the pinned Ruff version should be unchanged; local/editor runs on newer Ruff should align with CI instead of surfacing rules the project never opted into.Reviewed by Cursor Bugbot for commit 1324eb0. Bugbot is set up for automated code reviews on this repo. Configure here.