I just got Black and Pre-Commit set up for my Django repository.
I used the default config for Black from the tutorial I followed and it's been working great, but I am having trouble excluding my migrations files from it.
Here is the default configuration I've been using:
pyproject.toml
[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
I used Regex101.com to make sure that ^.*\b(migrations)\b.*$
matched apps/examples/migrations/test.py
.
[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| ^.*\b(migrations)\b.*$
)/
'''
When I add that regex line to my config file, and run pre-commit run --all-files
, it ignores the .git
folder but still formats the migrations files.