我在我的代码上运行 pylint:
pylint package --fail-under=8 --rcfile=pylintrc
这是我的rcfile:
[BASIC]
# Good variable names which should always be accepted, separated by a comma
good-names=i,j,k,e,_
# Private entries do not need documentation
# Yes, private entries must be marked with a single not a double underscore
no-docstring-rgx=_.*
[FORMAT]
# we follow a general practice
max-line-length=79
[MESSAGES CONTROL]
# I0011 - locally disabling ...
# If a pylint message is locally disabled - there is a reason for it. There is no need
# To show a warning
# C0203 - Metaclass method ... should have 'cls' as first argument
# pep8 says otherwise - lets stick with pep8 here
# R1705 - no-else-return] Unnecessary "else" after "return"
# Sometimes else at the end looks clearer, let's allow this.
disable=I0011, C0203, R1705
[REPORTS]
# set the output format. Available formats are text, parseable, colorized and html
output-format=text
# reasonable message template
msg-template=@{line}: [{msg_id} {symbol}] {msg}
[MASTER]
# given that numpy is a C extension it has to be white-listed
# same goes for MySQLdb exceptions
extension-pkg-whitelist=numpy,MySQLdb
[TYPECHECK]
# numpy has a bunch of dynamically created fields invisible for pylint
# they need to be ignored
ignored-modules = numpy
ignored-classes = numpy
[SIMILARITIES]
# Ignore similar imports, see:
# https://stackoverflow.com/questions/29206482/pylint-duplicate-code-false-positive
# It is better to disable this on imports, than on the whole file because
# of required imports.
ignore-imports=yes
似乎--fail-under
没有效果,即使分数低于 8 也不会退出。我相信这个功能相对较新,我也看过关于它的文档:
http://pylint.pycqa.org/en/latest/technical_reference/features.html。似乎无法弄清楚为什么它不起作用。任何线索在这方面都会有所帮助。
这是我的 pylint 版本:
pylint 2.8.2
astroid 2.5.6
Python 3.6.1 (default, Jul 13 2020, 15:20:59)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.32.59)]