Recommended 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.
Cost
Open source. MIT licence, free to use in any project.
How to do it
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
Using these examples: they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.
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
- Format all code with one tool in 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.