我试图触发PyLint错误E0106"返回带有生成器内的参数"。
以下内容会触发错误。
def tokenize(string):
for token in string.split(' '):
yield token
return "I ruin everything."
for t in tokenize("This sentence has five tokens."):
print t
PyLint输出:
************* Module tokenize
C: 1,0: Missing docstring
E: 4,0:tokenize: Return with argument inside generator
C: 1,0:tokenize: Missing docstring
以下内容不会触发错误。
def tokenize(string):
for token in string.split(' '):
yield token
return token
for t in tokenize("This sentence has five tokens."):
print t
PyLint输出:
************* Module tokenize
C: 1,0: Missing docstring
C: 1,0:tokenize: Missing docstring
环境
操作系统:Ubuntu 12.04 LTS 64位
Python版本:2.7.3
pylint --version
的输出:
No config file found, using default configuration
pylint 0.25.0,
astng 0.23.0, common 0.57.1
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3]