如何解决升级到 Twisted 21.2.0 时出现 Mypy 输入错误
尝试将 Twisted 包从 20.3.0 升级到 21.2.0。
升级后,在运行 Mypy 时访问反应器时出现以下错误(来自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标记反应器的类型?我应该在每次使用之前将它转换为一种类型吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。