How to use typeshed with mypy?

别等时光非礼了梦想. 提交于 2019-12-12 16:36:53

问题


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. The mypy repo does contain reference to the typeshed repo, but pip installing it doesn't not download it.


回答1:


Mypy comes bundled with typeshed by default, so you shouldn't need to do anything -- simply doing pip install mypy will install it correctly.

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.




回答2:


Since version 0.4.6 mypy has the option --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.



来源:https://stackoverflow.com/questions/38934177/how-to-use-typeshed-with-mypy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!