0

.pylintrc在我的项目根目录中使用 a 来控制我在项目上运行它时收到的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
4

2 回答 2

3

要跨多行指定 a disable,请使用以下命令:

disable=relative-import,
    invalid-name,
    missing-docstring

那是:

  • 没有连续字符\;和
  • 缩进后续行。
于 2017-10-02T09:20:54.163 回答
-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 不报告 hte 三个消息

于 2019-10-17T04:54:35.177 回答