Python 类型检查器 mypy : subprocess. STARTUPINFO 未定义

标签 python mypy

当使用subprocess.STARTUPINFO时等等 mypy 提示:

error: Name 'subprocess.STARTUPINFO' is not defined
error: Module has no attribute "STARTUPINFO"
error: Module has no attribute "STARTF_USESHOWWINDOW"
error: Module has no attribute "SW_HIDE"

这是因为 https://github.com/python/mypy/issues/1990编辑:这是因为它丢失了here

有解决办法吗?

最佳答案

看起来你的预感是正确的:这些常量似乎在 typeshed 中丢失了。

您应该在 typeshed 存储库上提出问题,或者甚至只是提出拉取请求并自己添加它们。如果你足够快地接受它们,这些更改可能会在下一个 mypy 版本中被及时接受,我相信是在本周五。 (如果没有,这些更改将成为下一个版本的一部分,大约一个月后?)

在此期间,您可以通过 # type:ignore 的某种组合以及配置 mypy 处理导入的方式来抑制这些错误。请参阅:

...了解详情。

或者,您可以克隆 typeshed,在本地修改它,并通过 --custom-typeshed-dir 命令行参数指示 mypy 使用 typeshed 的本地副本。

关于Python 类型检查器 mypy : subprocess. STARTUPINFO 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49734577/

相关文章:

python - 添加解释器时Pycharm错误,权限被拒绝

python - mypy 错误 : Incompatible types in assignment (expression has type "Dict[<nothing>, <nothing>]", 目标的类型为 "List[str]")

python - mypy 虚假错误 : "module" has no attribute "XPath" with etree

python - 使用 Union 类型设置默认值

python - 选择第一个下拉列表后,第二个下拉列表发生变化

python - 是否可以从 pymongo ping mongodb

python - 提取并替换字符串中占位符之间的子字符串

python - 如何设置 sys.modules ["m"]=<当前模块>

python - MyPy 不允许将通用属性标记为最终属性

python - 如何在保留类型的同时重写类 __init__ 方法