如何在 mypy 中使用 typeshed?

How to use typeshed with mypy?

我克隆了 typeshed 但我不知道如何告诉 mypy 使用它包含的类型提示,我在 mypy --help 中看不到任何选项。 mypy 存储库确实包含对 typeshed 存储库的引用,但 pip 安装它不会下载它。

默认情况下,Mypy 与 typeshed 捆绑在一起,因此您无需执行任何操作——只需执行 pip install mypy 即可正确安装它。

请注意,typeshed 不是 Python 模块,因此无法导入它或从 Python 程序访问它,除非您从字面上查看文件系统中的位置存根已存储。

因为版本 0.4.6 mypy 有选项 --custom-typeshed:

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

查看 command line reference for the documentation and Issue 2323 了解详细信息。