Skip to content
Latchkey

ruff format --check "would reformat" in CI

ruff format --check does not change files; it reports which ones differ from ruff's formatter output, prints how many "would be reformatted", and exits 1 if any do.

What this error means

The format check prints "Would reformat: path/to/file.py" lines, a summary like "1 file would be reformatted", and exits with code 1.

ruff
Would reformat: app/main.py
1 file would be reformatted, 12 files already formatted

Common causes

Files were not formatted with ruff

The listed files differ from ruff format output, so --check flags them and fails.

A ruff version change shifted formatting

A different ruff version formats slightly differently than the one used when the files were committed.

How to fix it

Format and commit

  1. Run ruff format to apply formatting.
  2. Commit the changes.
  3. Re-run ruff format --check to confirm exit 0.
Terminal
ruff format .
ruff format --check .

Pin ruff across local and CI

Lock the ruff version so local format and CI --check agree.

pyproject.toml
# pyproject.toml
[tool.ruff]
required-version = "0.5.0"

How to prevent it

  • Run ruff format in a pre-commit hook.
  • Pin the ruff version in your project config.
  • Keep formatter settings in one shared config.

Frequently asked questions

What causes "ruff "N files would be reformatted""?
The listed files differ from ruff format output, so --check flags them and fails.
How do I fix ruff "N files would be reformatted"?
Format and commit

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card