当我跳过整个文件的类型检查时,如何避免出现“模块...没有属性”错误?

时间:2020-06-27 19:36:28

标签: python mypy typechecking

我有一个包含文件a.py的文件夹:

# type: ignore

def foo() -> None:
    pass

b.py

from a import foo

Mypy不喜欢这样:

% mypy *
b.py:1: error: Module 'a' has no attribute 'foo'

我可以通过更改b.py来解决此问题,

from a import foo  # type: ignore[attr-defined]

但是,如果我在很多地方导入a,那真的很不舒服。我可以忽略整个模块而不必忽略每个模块的导入吗?

0 个答案:

没有答案