3

我将使用这个简单的 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 的默认配置?这样我就可以在上面添加我的设置。

4

1 回答 1

1

I just check the pylintrc file in the source tree of the pylint project. Not sure whether they are really the default values, but appears to be pretty close.

于 2018-08-30T21:14:38.047 回答