Skip to content

Align black pre-commit hook version with requirements.txt - #582

Merged
vimalloc merged 1 commit into
vimalloc:mainfrom
guidoiaquinti:align-black-precommit-version
Oct 5, 2026
Merged

vimalloc merged 1 commit into
vimalloc:mainfrom
guidoiaquinti:align-black-precommit-version

Conversation

@guidoiaquinti

Copy link
Copy Markdown
Contributor

The black pre-commit hook was pinned to 22.3.0, but requirements.txt pins black==23.12.1. So the pre-commit hook and the dev environment could format code differently. Found while working on #581.

This PR only aligns the two versions; it doesn't upgrade black. Moving to the latest stable black (26.10.0) means first deciding what to do about another pre-commit hook:

  • Since 24.1.0, black always puts a blank line between a module docstring and the code after it, and this can't be turned off.
  • reorder-python-imports deletes that same blank line. That's true of the pinned v1.5.0 and of the latest v3.17.0.
  • The two hooks keep undoing each other, so pre-commit run --all-files never passes. Currently this affects flask_jwt_extended/default_callbacks.py and tests/test_typing.py.

Options for a follow-up:

  1. Replace reorder-python-imports with isort (--profile black --force-single-line-imports). This keeps the one-import-per-line style and works with black.
  2. Move to Ruff (recommended) for import sorting, linting and formatting, replacing reorder-python-imports, flake8 and black. A bigger change, but it means fewer tools to maintain.

The pre-commit hook pinned black 22.3.0 while requirements.txt pins
23.12.1, so local hooks and the dev environment could format code
differently. Bump the hook to 23.12.1 to match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vimalloc

vimalloc commented Oct 5, 2026

Copy link
Copy Markdown
Owner

I'll take a look at the black alternatives when I have some time here 👍

@vimalloc
vimalloc merged commit 11785e0 into vimalloc:main Oct 5, 2026
14 checks passed
@guidoiaquinti

Copy link
Copy Markdown
Contributor Author

I'll take a look at the black alternatives when I have some time here 👍

Thanks! If you have any pointers or personal preferences, I’d also be happy to put together a PR. Personally, since switching to ruff/ty and uv, I haven’t looked back :)

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