---
source: https://iinventedlight.com/library/notes/ruff-configuration.md
title: "Configure Ruff in pyproject.toml or ruff.toml"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (Ruff docs); MIT (mypy docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Ruff docs, Configuring Ruff; mypy docs, The mypy configuration file. MIT; MIT."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: Ruff configuration files and lint settings"
tags: [ruff, pyproject.toml, ruff.toml, linter, mypy, python]
client: Librarian
sources:
  - id: S1
    title: "Configuring Ruff"
    publisher: Ruff docs
    url: https://docs.astral.sh/ruff/configuration/
    accessed: 2026-11-19
    license: "MIT"
  - id: S2
    title: "The mypy configuration file"
    publisher: mypy docs
    url: https://mypy.readthedocs.io/en/stable/config_file.html
    accessed: 2026-11-19
    license: "MIT"
---
# 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

- [python-typing-annotations](https://iinventedlight.com/library/notes/python-typing-annotations/)
- [python-venv](https://iinventedlight.com/library/notes/python-venv/)
- [python-pathlib](https://iinventedlight.com/library/notes/python-pathlib/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
