Skip to content

Add black pre-commit hook #19712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2025
Merged

Add black pre-commit hook #19712

merged 3 commits into from
Jun 12, 2025

Conversation

redsun82
Copy link
Contributor

@redsun82 redsun82 commented Jun 10, 2025

This switches codegen from the autopep8 formatting to the black one, and applies it to bulk_mad_generator.py as well. We can enroll more python scripts to it in the future.

This switched `codegen` from the `autopep8` formatting to the `black`
one, and applies it to `bulk_mad_generator.py` as well. We can enroll
more python scripts to it in the future.
@redsun82 redsun82 requested review from paldepind and Copilot June 10, 2025 10:27
@redsun82 redsun82 requested a review from a team as a code owner June 10, 2025 10:27
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the black formatter as a pre-commit hook and reformats all existing Python code in misc/codegen (and related tests) with black.

  • Switch from autopep8 to black in .pre-commit-config.yaml
  • Apply black formatting to test files and code generator modules under misc/codegen

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.pre-commit-config.yaml Replaced autopep8 hook with black hook
misc/codegen/test/test_dbscheme.py Reformatted with black (line breaks, quoting)
misc/codegen/test/test_cppgen.py Reformatted with black
misc/codegen/test/test_cpp.py Reformatted with black
misc/codegen/loaders/*.py Reformatted with black
misc/codegen/lib/*.py Reformatted with black
misc/codegen/generators/*.py Reformatted with black
misc/codegen/codegen.py Reformatted with black
Comments suppressed due to low confidence (2)

misc/codegen/test/test_dbscheme.py:18

  • [nitpick] Parameter name type shadows the built-in; consider renaming it (e.g., col_type) to avoid confusion.
"type,binding,lhstype,rhstype",

misc/codegen/codegen.py:102

  • [nitpick] Remove the trailing comma after the add_argument call to avoid inadvertently creating a tuple expression and improve readability.
    ),

@redsun82 redsun82 requested a review from a team as a code owner June 10, 2025 10:30
Also remove the python setup stage as it shouldn't be necessary any more
seen that bazel uses a specific bundled one.
Copy link
Contributor

@esbena esbena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming the new dependency on black does not require changes to Actions/Local setups/guides.

@redsun82 redsun82 merged commit 55eb9fb into main Jun 12, 2025
17 checks passed
@redsun82 redsun82 deleted the redsun82/python-black branch June 12, 2025 18:49
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.

2 participants