Skip to content
Latchkey

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

  1. Run ruff check --fix to apply safe fixes.
  2. Run ruff format to normalize formatting.
  3. 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 --fix and ruff format before pushing.
  • Pin the ruff version so rule sets are stable across machines.
  • Add a pre-commit hook so violations never reach CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →