chore(ci): enforce Python formatting via pre-commit to prevent recurring CI failures #707
+173
−31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Standardize Python Formatting via pre-commit + Black
Summary
This PR introduces a permanent, contributor-friendly solution to recurring Python formatting failures (e.g.,
PYTHON_BLACKerrors) by standardizing Python formatting using pre-commit + Black.The goal is to make CI behavior predictable, reduce contributor friction, and prevent formatting-only PR failures across both internal and fork-based contributions.
What Changed
docs/CONTRIBUTING.md.Why This Change?
Several recent PRs failed CI due to Python Black formatting issues, even when the underlying logic was correct. This caused unnecessary back-and-forth and blocked otherwise valid contributions.
By enforcing formatting consistently:
This aligns OpenCRE with common best practices used in mature open-source projects.
How This Works
In CI
For Contributors (Recommended Local Workflow)
Contributors can run the same checks locally that CI runs:
Command Details
pip install pre-commit: Installs the pre-commit framework (one-time setup).pre-commit install: Installs Git hooks so formatting checks run automatically on every commit.pre-commit run --all-files: Runs Black against the entire repository (useful before opening a PR or when CI fails).Scope
No functional code changes.
No behavior changes.
Formatting, CI configuration, and documentation only.
Result
Eliminates recurring
PYTHON_BLACKCI failures.Establishes a single source of truth for Python formatting.
Improves contributor experience for both new and existing contributors.
Provides a long-term solution instead of repeated one-off fixes.