Skip to content
Latchkey

black "would reformat" (--check failed) in CI

black ran with --check, which reports differences without writing them. It found files that are not formatted to black's style and exits non-zero so CI fails - the fix is to run black for real and commit the result.

What this error means

The format gate fails with "would reformat <file>" and "Oh no! ... N files would be reformatted" from black --check, exit code 1.

python
would reformat app/service.py
Oh no! 1 file would be reformatted, 11 files would be left unchanged.

Common causes

Code was committed without running black

Edits were pushed without formatting, so --check finds a diff against black's style.

A black version mismatch changes formatting

A different black version locally vs CI produces different output, so files pass locally but fail in CI.

How to fix it

Run black and commit

  1. Run black . to apply formatting.
  2. Commit the reformatted files.
  3. Re-run CI; --check now passes.
Terminal
black .

Pin black so versions match

Pin the exact black version so local and CI format identically.

Terminal
pip install "black==24.8.0"

How to prevent it

  • Run black . before pushing.
  • Pin the black version across local and CI.
  • Add black to pre-commit so formatting is enforced early.

Related guides

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