ruff(1)
A fast Python linter and code formatter written in Rust that checks code for style, logic errors, and security issues.
Synopsis
ruff check [OPTIONS] [PATH]...Description
Ruff is an extremely fast Python linter combining the functionality of Pylint, Flake8, isort, and other tools into a single tool. It performs static analysis to detect bugs, style violations, and security issues in Python code. Ruff can also format code automatically, similar to Black.
The tool supports hundreds of linting rules organized by error code prefixes (E/W for style, F for logic errors, C for complexity, etc.). It integrates seamlessly into CI/CD pipelines and modern editors due to its speed and LSP support.
Common options
| Flag | What it does |
|---|---|
check | Lint files and report violations (default command) |
format | Format Python files in-place |
--select=RULES | Enable specific rules by code, e.g., --select=E501,W291 |
--ignore=RULES | Ignore specific rules by code, e.g., --ignore=E501 |
--fix | Automatically fix violations that can be corrected |
--unsafe-fixes | Allow fixes that may change code behavior |
--line-length=NUM | Set line length limit (default: 88) |
--config=PATH | Use a specific configuration file |
--output-format=FORMAT | Set output format: text, json, github, or gitlab |
--watch | Watch files and re-lint on changes (requires installation extra) |
--exit-zero | Exit with code 0 even if violations found |
--show-fixes | Display fix details alongside violations |
Examples
Lint all Python files in the current directory and subdirectories
ruff check .Lint the src/ directory and automatically fix all auto-fixable violations
ruff check --fix src/Format a single Python file in-place to match Black style
ruff format myfile.pyCheck only for line-too-long and trailing-whitespace errors in app.py
ruff check --select=E501,W291 app.pyLint with custom settings: ignore E203/E501, set line length to 100
ruff check --ignore=E203,E501 --line-length=100 .Output linting results as JSON for programmatic parsing
ruff check --output-format=json . > issues.jsonApply all fixes including ones that may alter code behavior
ruff check --unsafe-fixes --fix src/Display fixes available but exit successfully regardless of violations
ruff check --show-fixes --exit-zero .