我有:
\nfoo/\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 bar.py\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 baz\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 alice.py\nRun Code Online (Sandbox Code Playgroud)\n在 中bar.py,我导入 Alice,它是一个空类,除了name属性设置为之外什么都没有"Alice"。
from baz.alice import Alice\n\na = Alice()\nprint(a.name)\nRun Code Online (Sandbox Code Playgroud)\n这可以正常运行:
\n$ python foo/bar.py\nAlice\nRun Code Online (Sandbox Code Playgroud)\n但 mypy 抱怨道:
\n$ mypy --version\nmypy 0.910\n$ mypy --strict .\nfoo/bar.py:1: error: Cannot find implementation or library stub for module named "baz.alice"\nfoo/bar.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports\nFound 1 error in 1 file (checked 6 source files)\nRun Code Online (Sandbox Code Playgroud)\n为什么 mypy 会抱怨?
\n