我将使用这个简单的 Python 文件来说明我的问题:
import os
for i in range( -500, 0 ):
print i
我在这个文件上运行 Pylint 并收到一条消息:
$ pylint foobar.py
************* Module foobar
W: 1, 0: Unused import os (unused-import)
现在我想禁用类型的警告消息unused-import
。但我想在 Pylint 的默认配置之上添加它。
我认为这给了我 Pylint 的默认配置,因为帮助--generate-rcfile
说它生成当前配置:
$ pylint --generate-rcfile > pylintrc
当我在同一个文件上再次运行 Pylint 时,我现在收到更多消息:
************* Module foobar
C: 3, 0: No space allowed after bracket
for i in range( -500, 0 ):
^ (bad-whitespace)
C: 3, 0: No space allowed before bracket
for i in range( -500, 0 ):
^ (bad-whitespace)
C: 1, 0: Missing module docstring (missing-docstring)
W: 1, 0: Unused import os (unused-import)
为什么bad-whitespace
只有在生成 pylintrc 后才会触发消息?默认是bad-whitespace
禁用的吗?如何获得 pylint 的实际默认配置?
那么,如果--generate-rcfile
没有给我默认配置,它输出的配置选项是什么?如何以 pylintrc 格式获取 Pylint 的默认配置?这样我就可以在上面添加我的设置。