[英]How to install mypy-lang on python 2.7?
The new version should support 2.7, but pip-installing it fails with a SyntaxError on a line with python 3 type-annotation syntax (which is kinda ironic): 新版本应该支持2.7,但是pip安装它失败了,并且在一行中使用了python 3类型注释语法的SyntaxError(这有点讽刺):
Traceback (most recent call last):
...
from mypy import git
File "mypy/git.py", line 10
def is_git_repo(dir: str) -> bool:
^
SyntaxError: invalid syntax
You can't run Mypy on Python 2. The project's README is specific about this: 你不能在Python 2上运行Mypy。项目的自述文件具体如下:
You need Python 3.2 or later to run mypy.
您需要Python 3.2或更高版本才能运行mypy。
You can still use it on Python 2 code though. 您仍然可以在Python 2代码上使用它 。 Just use the comment-based annotations and give Mypy the
--py2
flag. 只需使用基于注释的注释,并为Mypy提供
--py2
标志。 You also need the typing library for Python 2, which you can install using pip: 您还需要Python 2的输入库,您可以使用pip进行安装:
pip install typing
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.