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
- Run
black .to apply formatting. - Commit the reformatted files.
- Re-run CI;
--checknow 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
ruff lint errors / "would reformat" failing CIFix ruff failing CI with lint violations or "would reformat" - ruff found rule violations or formatting diffe…
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…