是否可以使用自定义 rcfile 和 仅错误标志运行 pylint?我希望 pylint 在典型用法中报告警告,但是当检查在我们的 CI 服务器上运行时,我想使用 --errors-only。
例如,假设我有 test.py:
"""test.py -- a test of pylint's error-handling."""
def some_method():
"""Just a method."""
print 'hi'
return 2
和一个自定义的 pylintrc 文件,它应该抑制报告和打印语句错误:
# custom-pylintrc
[REPORTS]
# Disable the reporting and just show messages.
reports=no
[MESSAGES CONTROL]
disable=print-statement
当我单独使用 pylintrc 文件时,我没有收到任何错误,但传递标志会显示一个错误,我预计该错误会被 rcfile 抑制。
$ pylint test.py --rcfile=custom-pylintrc # passes with no output
$ pylint test.py --rcfile=custom-pylintrc --errors-only
************* Module test
E: 5, 4: print statement used (print-statement)
我想我也想吃蛋糕 -- 我可以使用 rcfile 和标志吗?
请您参考如下方法:
CI 可以运行不使用 pylintrc 的自定义命令:
pylint --errors-only --disable=print-statement test.py
