Configure Ruff in pyproject.toml or ruff.toml
Answer: Ruff can be configured through a pyproject.toml, ruff.toml, or .ruff.toml file. The configuration strategy is the same when you use Ruff as a linter, as a formatter, or as both. In pyproject.toml, settings go under [tool.ruff]. mypy can share that file: it looks for a [tool.mypy] section in pyproject.toml after mypy.ini and .mypy.ini.
Ruff files and sections
If left unspecified, Ruff's default configuration is equivalent to the example [tool.ruff] table in the docs. Set target-version so rule selection matches a Python version, for example "py311". Lint options go under [tool.ruff.lint]. Use extend-select to turn on extra rule codes, for example the flake8-bugbear (B) rules, in addition to the defaults. Use ignore to turn codes off, for example E501 for line-length violations. [tool.ruff.lint.per-file-ignores] applies ignores in selected files and in selected subdirectories. Formatter options go under [tool.ruff.format].
| pyproject.toml | ruff.toml | |---|---| | pyproject.toml | Settings under [tool.ruff] | | ruff.toml or .ruff.toml | A Ruff-only config file | | [tool.ruff.lint] | Rule selection, ignore, extend-select | | [tool.ruff.lint.per-file-ignores] | Ignores for named files or globs | | [tool.ruff.format] | Formatter settings |
See Settings for every configuration option, and Default Rules for the enabled rules.
mypy in the same project
mypy searches configuration files in this order: mypy.ini, .mypy.ini, then pyproject.toml with a [tool.mypy] section, then setup.cfg with a [mypy] section. If this method finds no configuration file, mypy then looks in user config locations. The --config-file flag has the highest precedence and must point at a valid configuration file. It is important to understand that there is no merging of configuration files.
See also
Claims
- id: C1 claim: Ruff reads pyproject.toml, ruff.toml, or .ruff.toml. source: S1 evidence: "configured through a pyproject.toml , ruff.toml , or .ruff.toml file"
- id: C3 claim: Lint settings live under [tool.ruff.lint], including per-file-ignores. source: S1 evidence: "[tool.ruff.lint.per-file-ignores]"
- id: C4 claim: mypy also reads a [tool.mypy] section in pyproject.toml. source: S2 evidence: "pyproject.toml (containing a [tool.mypy] section)"
Sources
- [S1] Configuring Ruff. Ruff docs. https://docs.astral.sh/ruff/configuration/ . License: MIT. Accessed 2026-11-19.
- [S2] The mypy configuration file. mypy docs. https://mypy.readthedocs.io/en/stable/config_file.html . License: MIT. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Ruff docs, Configuring Ruff; mypy docs, The mypy configuration file. MIT; MIT. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Ruff docs, Configuring Ruff; mypy docs, The mypy configuration file. MIT; MIT.
Cite this
iinventedlight. 2026. "Configure Ruff in pyproject.toml or ruff.toml." iinventedlight Library, iil:note:k44vpd3a, version of 2026-11-19. https://iinventedlight.com/library/notes/ruff-configuration/. License: CC-BY-4.0.
@misc{iil_note_k44vpd3a,
author = {{iinventedlight}},
title = {{Configure Ruff in pyproject.toml or ruff.toml}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/ruff-configuration/},
note = {Permanent ID iil:note:k44vpd3a. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- ruff-configuration.table.json (table; CC-BY-4.0)
- ruff-configuration.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ruff-configuration.md.