我希望只对某些特定模块使用disable_error_code = ["name-defined"]
和ignore_missing_imports = true
选项,但我很难使其工作起来。以下是我不工作的pyproject.toml
文件的摘录
[tool.mypy]
python_version = "3.9"
disallow_untyped_defs = true
show_error_codes = true
no_implicit_optional = true
warn_return_any = true
warn_unused_ignores = true
exclude = ["scripts", "docs", "test"]
[[tool.mypy.overrides]]
module = [
"firstmodule",
"secondmodule",
"utils",
"config",
]
disable_error_code = ["name-defined"]
ignore_missing_imports = true
更确切地说,如果我保持上面提到的disable_error_code = ["name-defined"]
,那么我会得到以下类型的错误
pyproject.toml: [module = "utils"]: Per-module sections should only specify per-module flags (disable_error_code)
如果我保持上面所示的ignore_missing_imports = true
,那么它将被忽略,并且由于缺少导入而导致的错误将被提示。
如果我将上述两个选项移到[tool.mypy]
下,则一切正常。
发布于 2022-10-25 17:28:33
我还想有选择地禁用那些还没有类型提示的包的警告,这种方法似乎适用于我:
[[tool.mypy.overrides]]
module = "firstmodule.*"
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "secondmodule.*"
ignore_missing_imports = true
https://stackoverflow.com/questions/73746639
复制相似问题