Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

Adds black Python formatter to the existing pre-commit hook, auto-installed via npm install.

Changes

  • pyproject.toml: Added black>=24.0.0 to dev dependencies with standard configuration (88 line length, py311/py312 targets)

  • pre-commit hook:

    • Auto-activates .venv when present
    • Runs black on staged Python files before ruff/mypy
    • Auto-formats and prompts re-stage if needed
    • Fixed Python file detection (git glob patterns → grep)
  • Documentation: Updated .githooks/README.md with black workflow and requirements

Behavior

First commit attempt with unformatted code:

$ git commit -m "Add feature"

🔍 Running linting checks on Python files...
  ✓ Running black...

❌ Black formatting check failed! Auto-formatting files...
reformatted tests/example.py

✅ Files have been auto-formatted with black.
   Please stage the formatted files and commit again:
   git add tests/example.py

Re-stage and commit succeeds:

$ git commit -m "Add feature"

🔍 Running linting checks on Python files...
  ✓ Running black...
  ✓ Black formatting check passed
  ✓ Running ruff...
  ✓ Ruff passed
✅ All linting checks passed!

Gracefully degrades if black not installed (warns but allows commit).

Original prompt

This section details on the original issue you should resolve

<issue_title>add black formatting to git hooks</issue_title>
<issue_description>make sure this hook is also installed by npm install</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Added black>=24.0.0 to dev dependencies in pyproject.toml
- Configured black settings with line-length=88 and Python 3.11/3.12 targets
- Updated pre-commit hook to:
  - Activate virtualenv automatically
  - Run black on staged Python files (auto-formats if needed)
  - Detect Python files correctly using grep
- Updated .githooks/README.md to document black formatting
- Hook is installed via npm install (postinstall script)

Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
Copilot AI changed the title [WIP] Add black formatting to git hooks Add black formatting to pre-commit hook with npm install Feb 8, 2026
Copilot AI requested a review from thawn February 8, 2026 15:37
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.

add black formatting to git hooks

2 participants