该项目的测试结构如下:
├── app
| └── db
| └── postgres.py
| └── postgres.py
└── postgres.py
如果您不设置配置,调用poetry run mypy . | grep postgres
将提供以下内容:
postgres.py:2: error: Unsupported operand types for + ("str" and
"float") [operator]
app/postgres.py:2: error: Unsupported operand types for + ("str"
and "float") [operator]
app/db/postgres.py:11: error: "Constraint" has no attribute
"columns" [attr-defined]
但是,我的目标是排除一个目录db
或至少一个文件app/db/postgres.py
,因此我pyproject.toml
添加:
[tool.mypy]
exclude = ["postgres.py", "db", "app/db", "db/postgres.py", "app/db/postgres.py"]
我跟注poetry run mypy . | grep postgres
。结论:
app/db/postgres.py:11: error: "Constraint" has no attribute "columns" [attr-defined]
由于某种原因,在第二层嵌套中,mypy
它不想尊重exclude
。看起来问题甚至不在这个参数上。有人可以帮忙吗?