我在项目根目录中使用.pylintrc
来控制我在项目中运行时收到的 PyLint 消息。
pylintrc中有许多选项可以使用逗号分隔的值列表。例如:
[MASTER]
disable=relative-import,invalid-name,missing-docstring
在我的实际pylintrc中,这个值列表可能很长。 有没有办法指定这样的值,每行一个?
这不起作用:
disable=relative-import,\
invalid-name,\
missing-docstring
这也不起作用:
disable=relative-import
disable+=invalid-name
disable+=missing-docstring
答案 0 :(得分:1)
要在多行中指定disable
,请使用以下命令:
disable=relative-import,
invalid-name,
missing-docstring
那是:
\
;和答案 1 :(得分:-1)
Em,您可以逐行添加配置,我在项目中使用了它。
pylint将关键字disable
解释为:
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
如果您可以禁用其他功能,例如在我的项目中,请pylint将此信息提供给我,
C0116: Missing function or method docstring (missing-function-docstring)
R0201: Method could be a function (no-self-use)
R1705: Unnecessary "elif" after "return" (no-else-return)
但是我想忽略三个消息,所以我将它们添加到disable
标签中,像这样
disable=unnecessary-lambda,
no-else-return,
too-many-branches
然后pylint不报告三则消息