在这个代码片段中
def add(x:int, y:int) -> int:
return x + y
有些函数注释仅在Python3.0之后才受支持
当我为这个python代码执行flake8时:
$ flake8 7.3.py -vv
checking 7.3.py
def add(x: int, y: int) -> int:
return x + y
7.3.py:1:11: E901 SyntaxError: invalid syntax
我得到了无效语法错误,但它应该是有效语法。如何使用flake8检查仅在Python 3.x中支持的语法?
关于reddit(here),我有答案:
所以你需要用pip3来安装flake8,而不是pip。
在OSX上对我来说
这对我有用。:)
见:https://bugs.launchpad.net/pyflakes/+bug/989203
NB:虽然此错误报告指出了某种级别的解决方案,但测试最新版本的pyflakes
0.8.1
这种缺少Python 3注释的情况仍然存在。我想你得另外向pyflakes提交一个新的功能请求。
pyflakes Bugs
更新(20140514):
事实证明,这个问题的实际答案是运行
pyflakes
或flake8
在Python3.x而不是Python2.x下所以做这样的事情:
见:http://codepad.org/9BKxSZaD
为Mac+py2+py3+venv工作:
相关问题 更多 >
编程相关推荐