Skip to content

Conversation

@PRAteek-singHWY
Copy link
Contributor

@PRAteek-singHWY PRAteek-singHWY commented Jan 11, 2026

Standardize Python Formatting via pre-commit + Black

Summary

This PR introduces a permanent, contributor-friendly solution to recurring Python formatting failures (e.g., PYTHON_BLACK errors) 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

  • Repository-wide pre-commit configuration: Added a config file to enforce Python formatting with Black.
  • CI Update: Updated Continuous Integration to rely on pre-commit for Python formatting.
  • Super-Linter Adjustment: Disabled Python Black validation in Super-Linter to avoid duplicate or conflicting checks.
  • Documentation: Documented the workflow and contributor expectations clearly in 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:

  • Actionable Feedback: Contributors get fast, actionable feedback locally.
  • Deterministic CI: CI failures become deterministic and easy to fix.
  • Maintainer Efficiency: Maintainers avoid repeatedly applying the same formatting fixes manually.
  • Equality: Fork-based contributors are treated the same as internal contributors.

This aligns OpenCRE with common best practices used in mature open-source projects.


How This Works

In CI

  • All PRs (including forks) run pre-commit checks.
  • Python formatting is enforced via Black.
  • Super-Linter continues to run for non-Python checks only.

For Contributors (Recommended Local Workflow)

Contributors can run the same checks locally that CI runs:

pip install pre-commit
pre-commit install
pre-commit run --all-files

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_BLACK CI 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant