ruff lint errors / "would reformat" failing CI
ruff ran in check mode and found code that violates an enabled rule or differs from ruff format output. In CI it exits non-zero to fail the job, listing each violation and whether it is auto-fixable.
What this error means
The lint step fails with "Found N errors" from ruff check, or "would reformat: ..." from ruff format --check, with a non-zero exit code.
python
app/main.py:12:1: F401 [*] 'os' imported but unused
app/main.py:30:80: E501 Line too long (94 > 88)
Found 2 errors.
[*] 1 fixable with the `--fix` option.Common causes
Code violates an enabled ruff rule
Unused imports, undefined names, or style rules the project enabled are present and ruff reports them.
Formatting differs from ruff format
ruff format --check finds files that are not formatted to ruff's style and reports "would reformat".
How to fix it
Auto-fix and reformat locally
- Run
ruff check --fixto apply safe fixes. - Run
ruff formatto normalize formatting. - Commit the changes and re-run CI.
Terminal
ruff check --fix .
ruff format .Pin ruff so rules do not drift
A floating ruff version can enable new rules; pin it so CI and local agree.
Terminal
pip install "ruff==0.5.7"How to prevent it
- Run
ruff check --fixandruff formatbefore pushing. - Pin the ruff version so rule sets are stable across machines.
- Add a pre-commit hook so violations never reach CI.
Related guides
black "would reformat" (--check failed) in CIFix black "would reformat" failing CI under --check - black found files whose formatting differs from its sty…
mypy "error: Module has no attribute" in CIFix mypy "error: Module X has no attribute Y" in CI - the type checker cannot find a name on a module, from m…
coverage.py "No source for code" in CIFix coverage.py "NoSource: No source for code" / "CoverageWarning: No source" in CI - coverage recorded a fil…