[英]Specify per-file-ignores with pyproject.toml and flake8
我正在使用 flake8(帶有 flakehell 但不應干擾)並將其配置保留在pyproject.toml
文件中。 我想添加一個per-file-ignores
配置,但沒有任何作用,並且沒有關於它應該如何在 toml 文件中格式化的文檔。
Flake8 文檔僅顯示“本機”配置文件格式:
per-file-ignores =
project/__init__.py:F401
setup.py:E121
other_project/*:W9
pyproject.toml 沒有描述/示例。
我試過:
per-file-ignores=["file1.py:W0621", "file2.py:W0621"]
和
per-file-ignores={"file1.py" = "W0621", "file2.py" = "W0621"}
兩者都默默地失敗並且沒有效果(仍然發出警告)。
使用 pyproject.toml 時,flake8/flakehell 中 per-file-ignores 設置的正確語法是什么?
flake8 不支持 pyproject.toml,只有.flake8
、 setup.cfg
和tox.ini
免責聲明:我是 flake8 的維護者
目前, pyproject-flake8允許您像這樣在pyproject.yoml
上編寫 flake8 設置。
# pyproject.toml
[tool.flake8]
exclude = ".venv"
max-complexity = 10
max-line-length = 100
extend-ignore = """
W503,
E203,
E701,
"""
per-file-ignores = """
__init__.py: F401
./src/*: E402
"""
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.