小编fre*_*pen的帖子

无法使 Mypy 使用 __init__.py 别名

以下是我的问题的最小示例:

[test/__init__.py]
from test.test1 import Test1
from test.test2 import Test2

[test/test1.py]
class Test1:
    pass

[test/test2.py]
from test import Test1

class Test2:
    pass
Run Code Online (Sandbox Code Playgroud)

模块或 __init__.py 的 Mypy 输出:

test/test2.py:1: error: Module 'test' has no attribute 'Test1'
Run Code Online (Sandbox Code Playgroud)

代码本身在 Python 2 和 Python 3 上都运行良好。

python mypy

5
推荐指数
1
解决办法
693
查看次数

标签 统计

mypy ×1

python ×1