The ruff check command

`ruff check` is the primary entrypoint to the Ruff linter. It accepts a list of files or directories and lints all discovered Python files, optionally fixing any fixable errors. When given a directory, Ruff searches for Python files recursively through that directory and all its subdirectories, and runs in the current directory by default. 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

Sources: The Ruff Linter | Ruff, Tutorial | Ruff

Rule selection

The set of enabled rules is controlled via the lint.select, lint.extend-select and lint.ignore settings. Ruff uses Flake8-style rule codes: an alphabetic prefix indicating the rule's source followed by digits, such as F401 from Pyflakes, E from pycodestyle or ANN from flake8-annotations. Selectors accept either a full rule code or any valid prefix, so selecting "E" and "F" while ignoring "F401" enables all pycodestyle and Pyflakes rules except that one. The special ALL code enables every rule, with conflicting pydocstyle rules such as D203 and D211 automatically disabled.

  • lint.select — explicit rule set
  • lint.extend-select — add to an inherited set
  • lint.ignore — exclude specific codes or prefixes
  • ALL — enable all rules, with conflicts resolved

Source: The Ruff Linter | Ruff

Recommended configuration guidance

The documentation suggests preferring lint.select over lint.extend-select so that the rule set stays explicit, and using ALL with discretion because it implicitly enables new rules on upgrade. A suggested starting point is a small set such as select = ["E", "F"], expanded one group at a time — for example adding "B" for flake8-bugbear. A broader popular selection combines pycodestyle (E), Pyflakes (F), pyupgrade (UP), flake8-bugbear (B), flake8-simplify (SIM) and isort (I). Rules are also grouped into categories including correctness, suspicious, complexity, performance, style, security, formatting and pedantic.

  • Start small and add rule groups incrementally
  • Prefer lint.select for an explicit rule set
  • Categories: correctness, suspicious, complexity, performance, style, security, formatting, pedantic

Source: The Ruff Linter | Ruff

Fixes and error suppression

Ruff marks certain violations as fixable and can resolve them automatically with `ruff check --fix`. In the documentation's tutorial, an unused `os` import is reported as F401 and marked fixable, then removed automatically by rerunning with --fix. The linter documentation also covers fix safety, disabling fixes, and error suppression at both line level and block level through noqa comments.

  • F401 unused imports reported as fixable
  • --fix applies available fixes in place
  • noqa comments for line-level and block-level suppression

Sources: The Ruff Linter | Ruff, Tutorial | Ruff

Configuration files and defaults

Ruff is configured through a pyproject.toml, ruff.toml or .ruff.toml file, with the same configuration strategy and semantics whether it is used as a linter, a formatter or both. To determine the settings for each Python file, Ruff looks for the first such file in the file's directory or any parent directory. The default configuration excludes a range of commonly ignored directories, sets a line length of 88 and an indent width of 4, allows fixes for all enabled rules when --fix is provided, and permits unused variables that are underscore-prefixed.

  • Config files: pyproject.toml, ruff.toml, .ruff.toml
  • Default line-length 88, indent-width 4
  • fixable = ["ALL"] by default
  • Settings can also be supplied through the Ruff Language Server

Sources: Configuring Ruff | Ruff, Tutorial | Ruff, Settings | Ruff

Relationship to Flake8, Black and the Ruff formatter

Ruff can be used as a drop-in replacement for Flake8 when used without or with a small number of plugins, alongside Black, and on Python 3 code; under those conditions it implements every Flake8 rule, meaning all F rules from Pyflakes and a subset of the E and W rules from pycodestyle. It also natively re-implements many popular Flake8 plugins and related tools, including autoflake, eradicate, flake8-bugbear, flake8-simplify, isort, mccabe, pep8-naming, pydocstyle and pyupgrade. The linter is compatible with Black out of the box as long as the line-length setting is consistent between the two, and defers implementing stylistic rules obviated by automated formatting. Because E501 checks lines against line-length subject to documented exceptions, line-length violations can still be reported when Black or ruff format is in use; the limit can be overridden with lint.pycodestyle.max-line-length.

  • Part of the Ruff CLI, alongside ruff format
  • Implements all Pyflakes F rules and a subset of E and W
  • Compatible with Black when line-length matches
  • lint.pycodestyle.max-line-length overrides the linter limit

Sources: FAQ | Ruff, The Ruff Formatter | Ruff, The Ruff Linter | Ruff

Sources

  1. FAQ | Ruff https://docs.astral.sh/ruff/faq/ Verified 03 Nov 2026
  2. Tutorial | Ruff https://docs.astral.sh/ruff/tutorial/ Verified 03 Nov 2026
  3. The Ruff Linter | Ruff https://docs.astral.sh/ruff/linter/ Verified 03 Nov 2026
  4. The Ruff Formatter | Ruff https://docs.astral.sh/ruff/formatter/ Verified 03 Nov 2026
  5. Settings | Ruff https://docs.astral.sh/ruff/editors/settings/ Verified 03 Nov 2026
  6. Configuring Ruff | Ruff https://docs.astral.sh/ruff/configuration/ Verified 03 Nov 2026

Last verified 03 Nov 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.