Ruff
Ruff lints and formats Python. Linting catches problems such as unused imports and unsorted imports. Formatting applies the repository's style consistently to Python files.
Configuration in this template
ruff.toml respects Git ignore files and sets the formatter's line-length target to 120. It uses double quotes, spaces for indentation, LF endings, and formatting for code in docstrings. The selected lint families cover Python style and correctness, import sorting, naming, and categories such as bug risks, modernization, and simplification. The long-line and complexity lint rules E501 and C901 are disabled.
Check or fix Python files
From your project root, run the two read-only checks.
ruff check .
ruff format --check .
Run ruff check --fix . or ruff format . when you want to apply fixes. The Prek configuration runs ruff-check with --fix as well as the separate ruff-format hook, so review any hook changes before retrying your commit.
Customize a rule
Edit [lint] in ruff.toml to change which rules are enforced. If generated files need different rules, scope the exception to those paths. Use ruff rule F401 to read an explanation of the unused-import rule or pass another rule code from your output. Ruff configuration reference