【发布时间】:2021-06-25 06:17:41
【问题描述】:
尝试将 Twisted 软件包从 20.3.0 升级到 21.2.0。
升级后,在运行 Mypy 时,我在访问 reactor(来自 twisted.internet import reactor)时遇到以下错误:
error: Module has no attribute "run" [attr-defined]
error: Module has no attribute "running" [attr-defined]
error: Module has no attribute "running" [attr-defined]
error: Module has no attribute "callLater" [attr-defined]
error: Module has no attribute "callInThread" [attr-defined]
error: Module has no attribute "callFromThread" [attr-defined]
error: Module has no attribute "spawnProcess" [attr-defined]
error: Module has no attribute "spawnProcess" [attr-defined]
使用reveal_type(reactor) 运行Mypy 时:
Revealed type is '_importlib_modulespec.ModuleType'
我试图了解在不忽略错误的情况下处理这种情况的最佳方法是什么,以便在使用反应器时进行类型检查。
有没有更好的方法来导入反应堆?有没有办法为 Mypy 标记反应器的类型?我应该在每次使用之前将其转换为类型吗?
【问题讨论】:
标签: twisted mypy python-typing