小编Cla*_*ltz的帖子

忽略黑色格式化程序的 pyproject.toml 文件中的 Django 迁移

我刚刚为我的 Django 存储库设置了BlackPre-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)

python regex django pre-commit.com pyproject.toml

9
推荐指数
2
解决办法
3304
查看次数

标签 统计

django ×1

pre-commit.com ×1

pyproject.toml ×1

python ×1

regex ×1