Skip to content
Latchkey

ruff extend-select: Add Rules to the Set

extend-select adds rule codes to whatever is already selected, unlike select which replaces the selection.

select sets the active rules; extend-select grows them. Knowing the difference avoids accidentally turning off everything else when you only meant to add one family.

What it does

extend-select, under [tool.ruff.lint], adds the listed rule codes to the existing selection rather than overriding it. The command-line equivalent is --extend-select. Use it to layer extra families (B, UP, SIM) onto a base set without restating the base.

Common usage

pyproject.toml
[tool.ruff.lint]
select = ["E", "F"]
extend-select = ["I", "B", "UP"]

Keys

ItemWhat it does
[tool.ruff.lint] selectReplaces the selection
[tool.ruff.lint] extend-selectAdds to the selection
--selectCommand-line override of selection
--extend-selectCommand-line addition to selection
extend-ignoreAdd to the ignore list similarly

In CI

Use select for the deliberate base set and extend-select for additions, so a teammate adding --select on the command line does not silently disable your extend-select families. Keep both in config for reproducibility.

Common errors in CI

Using select where you meant extend-select wipes out previously selected families, so rules you relied on stop firing and CI passes code it used to fail. Adding a new family via extend-select can fail a previously green build because more rules now apply. A typo in a code yields "Unknown rule selector" and exit 2.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →