我刚刚为我的 Django 存储库设置了Black和Pre-Commit。
我在我遵循的教程中使用了 Black 的默认配置,它运行良好,但我无法从中排除我的迁移文件。
这是我一直在使用的默认配置:
pyproject.toml
[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
Run Code Online (Sandbox Code Playgroud)
我使用Regex101.com来确保^.*\b(migrations)\b.*$
匹配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.*$
)/ …
Run Code Online (Sandbox Code Playgroud)