简体   繁体   English

如何在 mypy 中使用 typeshed?

[英]How to use typeshed with mypy?

I cloned typeshed but I can't figure out how to tell mypy to use the type hints it contains, I see no option in mypy --help.我克隆了typeshed但我不知道如何告诉 mypy 使用它包含的类型提示,我在 mypy --help 中看不到任何选项。 The mypy repo does contain reference to the typeshed repo, but pip installing it doesn't not download it. mypy 存储库确实包含对 typeshed 存储库的引用,但安装它的 pip 不会下载它。

Mypy comes bundled with typeshed by default, so you shouldn't need to do anything -- simply doing pip install mypy will install it correctly.默认情况下,Mypy 与 typeshed 捆绑在一起,因此您无需执行任何操作——只需执行pip install mypy正确安装它。

Note that typeshed is not a Python module, so it isn't possible to import it or otherwise access it from a Python program unless you literally look at the location in the filesystem the stubs are stored.请注意,typeshed 不是 Python 模块,因此不可能从 Python 程序导入或以其他方式访问它,除非您从字面上查看存根存储在文件系统中的位置。

Since version 0.4.6 mypy has the option --custom-typeshed :由于版本0.4.6 mypy有权选择--custom-typeshed

mypy --py2 --custom-typeshed ~/REPOS/PYTHON/mypy/typeshed my-thing.py

See command line reference for the documentation and Issue 2323 for the gory details.有关文档的命令行参考问题 2323 ,请参阅详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM