Linting & Formattingο
π§Ή Consistent linting and formatting keep the codebase clean and reduce review time. This project uses
rufffor both β it is fast, requires almost no configuration, and replaces the olderblack+pre-commitsetup.
βΉοΈ Note: This project no longer uses
pre-commit. Its checks were removed in favour of a CI-sidelintjob that runsruffon every pull request. The filename of this page is kept for backward-compatible links.
π The Toolsο
ruffβ linting, formatting, and type-annotation checks for Python. One tool covers all three jobs.
βοΈ Everyday Commandsο
Run these from the root of the project.
Lintο
ruff check .
Lint and autofixο
ruff check --fix .
Formatο
ruff format .
Verify formatting (what CI runs)ο
ruff format --check .
ruff format --check . does not modify any files β it exits non-zero if anything is not already formatted, which is exactly what the CI lint job does.
π€ Enforcement in CIο
Every pull request triggers a lint job in GitHub Actions that runs:
ruff check .
ruff format --check .
If either command fails, the job fails. To fix issues before pushing, run ruff check --fix . and ruff format . locally, then commit the result.
π Cheatsheetο
Task |
Command |
|---|---|
Lint |
|
Lint and autofix |
|
Format |
|
Verify formatting (CI) |
|