ruff --select and --ignore: Choose Rules
ruff --select enables rules by code or prefix and --ignore disables them, replacing the configured set when used together.
Rule selection is the core of how you tune Ruff. Codes like E, F, and I name whole families; you opt in and out by prefix.
What it does
ruff check --select takes rule codes or prefixes (E, F, I, B, UP, and many more) and makes them the active set. --ignore removes specific rules from whatever is selected. On the command line --select overrides the configured selection rather than adding to it; use --extend-select to add.
Common usage
ruff check --select E,F .
ruff check --select ALL --ignore D,ANN .
ruff check --select I . # import sorting only
ruff check --extend-select B,UP . # add to configured rulesFlags
| Flag | What it does |
|---|---|
| --select <codes> | Set the active rules (overrides config selection) |
| --ignore <codes> | Disable specific rules from the selection |
| --extend-select <codes> | Add rules on top of the configured selection |
| ALL | Special selector meaning every rule Ruff ships |
| --preview | Required to select rules still in preview |
In CI
Keep selection in pyproject.toml so it is identical for everyone, and reserve command-line --select for ad hoc runs. Selecting ALL is powerful but couples you to every future rule, so most teams select named families plus --extend-select.
Common errors in CI
"error: Unknown rule selector: XYZ" (exit 2) means a typo or a code that does not exist in this Ruff version; check ruff rule or ruff linter. A rule that is silently inactive may be in preview and need --preview. Selecting ALL can suddenly fail a build after an upgrade because new rules joined ALL.