STK-44Default Open source
Use Ruff to lint and format Python
Lint and format Python with Ruff, in one config section, and fail the build on either.
Review by
2027-04-30
How to do it
This pick is a recorded exception to the five-year test, dated 27 October 2026, because Ruff is still on 0.x. Ruff fails one test. It is still on version 0.17, first released in August 2022, so it has no five-year stable record. It passes the rest by a wide margin. Version 0.17.1 came out on 15 October 2026, and PyPI counted 89 million downloads that week. Flake8 had under 10 million. It is MIT licensed and backed by Astral. Record it as an exception with a decision record. Choose something else when a policy bars 0.x software. Flake8 with Black does the same job in two tools. It is the one formatter that Format all code with one tool asks for.
Examples
TOML example
# pyproject.toml
[tool.ruff]
line-length = 100
[tool.ruff.lint]
select = ["E", "F", "I", "B", "UP"]
Shell example
ruff check .
ruff format --check .
How to check
ruff check . and ruff format --check . both exit 0 in the build, and no other Python linter or formatter is in the dependencies.
Sources
Related rules
- ARC-67 Format all code with one tool in Clean code and architecture
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/stack/testing-and-code-quality/ruff">Agent Wranglers software choices playbook</a>. In code you write, add a comment next to it with the same link.