# Ruff Extremely fast Python linter and formatter from [Astral](https://astral.sh). Replaces flake8, isort, pycln, pyupgrade, Black, and most of pylint in a single tool. ## Commands ```bash ruff check . # lint ruff check --fix . # lint + auto-fix ruff check --watch . # lint on file change ruff format . # format (Black-compatible) ruff format --check . # check formatting without changing ruff rule E501 # explain a specific rule ruff linter # list all available linters ``` ## Configuration Supports `ruff.toml`, `.ruff.toml`, or `[tool.ruff]` in `pyproject.toml`. ```toml [tool.ruff] line-length = 88 # default, matches Black target-version = "py312" [tool.ruff.lint] select = [ "E", # pycodestyle errors "F", # pyflakes "I", # isort "B", # flake8-bugbear "UP", # pyupgrade "SIM", # flake8-simplify ] ignore = ["E501"] # line too long (let formatter handle it) unfixable = ["B"] # don't auto-fix bugbear [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] # unused imports OK in __init__ [tool.ruff.format] quote-style = "double" # default docstring-code-format = true ``` ### CLI overrides ```bash ruff check --config "lint.select = ['E', 'F']" . ``` ## Rule Categories | Code | Source | What it catches | |------|--------|-----------------| | `E`/`W` | pycodestyle | Style errors/warnings | | `F` | pyflakes | Unused imports, undefined names | | `I` | isort | Import sorting | | `B` | flake8-bugbear | Common bugs and design problems | | `UP` | pyupgrade | Outdated Python syntax | | `SIM` | flake8-simplify | Simplifiable code | | `N` | pep8-naming | Naming conventions | | `S` | flake8-bandit | Security issues | 800+ rules total. Full list: [docs.astral.sh/ruff/rules](https://docs.astral.sh/ruff/rules/) ## Modern Python Stack Ruff replaces most legacy tools. A minimal setup: ```bash ruff check --fix . # lint + fix (replaces flake8, isort, pycln, pylint) ruff format . # format (replaces Black) ty check . # type check (replaces mypy) — see [[ty]] ``` --- See also: [[uv]], [[ty]]