Scope and role within Ruff
The Ruff Linter is part of the Ruff toolchain, which also provides a formatter available via `ruff format`. It is documented on the Astral documentation site alongside Ruff's configuration reference, tutorial and FAQ. The linter re-implements the rules of Flake8 and a range of related Python code quality tools natively, so that a single binary can replace several separate tools.
- Drop-in replacement for Flake8 and dozens of its plugins
- Also covers isort, pydocstyle, pyupgrade and autoflake
- Implements every Flake8 rule when used without or with few plugins, alongside Black, on Python 3 code
- Natively re-implements tools including flake8-bugbear, flake8-simplify, pep8-naming, mccabe, pandas-vet and pygrep-hooks
- Part of the same CLI as the Ruff formatter
The ruff check command
`ruff check` is the primary entrypoint to the linter. It accepts a list of files or directories and lints all discovered Python files, searching recursively through subdirectories, and can optionally fix any fixable errors. The full list of supported options is available by running `ruff check --help`.
- `ruff check` — lint files in the current directory
- `ruff check --fix` — lint and fix fixable errors
- `ruff check --watch` — re-lint on change
- `ruff check path/to/code/` — lint a specific path
Rule selection
The set of enabled rules is controlled via the `lint.select`, `lint.extend-select` and `lint.ignore` settings. Ruff mirrors Flake8's rule code system, in which each code consists of a one-to-three letter prefix followed by three digits, such as F401; the prefix indicates the rule's source, for example F for Pyflakes, E for pycodestyle and ANN for flake8-annotations. Selectors accept either a full rule code or any valid prefix, and the special `ALL` code enables every rule, with conflicting pydocstyle rules such as D203 and D211 automatically disabled. The documentation recommends preferring `lint.select` over `lint.extend-select` for an explicit rule set, using `ALL` with discretion because upgrades implicitly enable new rules, and starting from a small selection such as `select = ["E", "F"]`.
- Rule codes use a letter prefix plus three digits, for example F401
- Selectors accept full codes or prefixes
- `ALL` enables all rules and resolves conflicting docstring rules
- Rules are grouped into categories including correctness, suspicious, complexity, performance, style, security, formatting and pedantic
Fixes and error suppression
Ruff marks certain violations as fixable and can resolve them automatically when `--fix` is passed. In the documentation tutorial, an unused `os` import is reported as `F401 [*] \`os\` imported but unused`, flagged as fixable, and removed by running `ruff check --fix`. The linter documentation also covers fix safety, disabling fixes, and suppressing errors at line, block and file level with `noqa` comments.
- Fixable violations marked with `[*]` in output
- Unused imports removed automatically by `ruff check --fix`
- `fixable` and `unfixable` settings control which rules may be fixed
- Inline blanket and code-specific `noqa` suppressions supported
Configuration
Ruff is configured through a `pyproject.toml`, `ruff.toml` or `.ruff.toml` file, and the same configuration strategy and semantics apply whether Ruff is used as a linter, a formatter, or both. Ruff looks for the first such file in a Python file's directory or any parent directory. Linter settings live under `[tool.ruff.lint]` in `pyproject.toml` or `[lint]` in a `ruff.toml` file; the default configuration sets a line length of 88, an indent width of 4, an empty `ignore` list, `fixable = ["ALL"]`, and excludes a range of commonly ignored directories.
- Supported files: `pyproject.toml`, `ruff.toml`, `.ruff.toml`
- Linter section: `[tool.ruff.lint]` or `[lint]`
- `--config` CLI flag and argfile support available
- Default line length 88, indent width 4
Editor integration
The Ruff Language Server exposes configuration options that customise its behaviour and can reuse an existing `pyproject.toml` or `ruff.toml` file to configure the linter and formatter. Settings are supplied when the server is initialised; VS Code provides a UI for this, while other editors may require manual configuration. In an editor, Ruff resolves configuration from three sources in order of precedence: individual settings such as `lineLength` or `lint.select`, the `ruff.configuration` field, and then any project configuration file.
- Configuration by file path or inline JSON object
- Inline JSON configuration added in Ruff 0.9.8
- `configurationPreference` options: editorFirst, filesystemFirst, editorOnly
- Examples documented for VS Code, Neovim and Zed
Relationship to formatters
The Ruff linter is compatible with Black out of the box provided the `line-length` setting is consistent between the two, and it defers implementing stylistic rules that automated formatting makes redundant. Line-length enforcement differs: Black and the Ruff formatter make a best-effort attempt to respect the limit but avoid wrapping in some cases, whereas the linter flags `E501` for any line exceeding `line-length`. The formatter documentation also lists lint rules that conflict with formatting, including `W191`, `E111`, `D203` and `Q000`.
- Compatible with Black when line-length matches
- `E501` may still fire under Black or `ruff format`
- Conflicting lint rules documented in the formatter guide
Sources
Last verified 19 Sep 2026. This entry is compiled from the public web pages listed above. Nothing here is stated that those pages do not, and each of them was read on the date shown.