我试图在Pylint 0.21.1中禁用警告C0321(“单行中有多个语句”——我经常将具有短单行结果的if语句放在同一行上)(如果有问题:astng 0.20.1, common 0.50.3,和Python 2.6.6 (r266:84292, 2010年9月15日,16:22:56))。
我尝试在Pylint配置文件中添加disable=C0321,但Pylint坚持报告它。这一行的变体(如disable=0321或disable=C321)被标记为错误,因此Pylint能够正确地识别该选项。它只是忽略它。
这是一个Pylint错误,还是我做错了什么?有办法解决这个问题吗?
我真的很想摆脱这些噪音。
编辑“C:\Users\Your User\AppData\Roaming\Code\User\settings.json”
并添加'python.linting。pylintArgs'和它的行在最后如下所示:
{
"team.showWelcomeMessage": false,
"python.dataScience.sendSelectionToInteractiveWindow": true,
"git.enableSmartCommit": true,
"powershell.codeFormatting.useCorrectCasing": true,
"files.autoSave": "onWindowChange",
"python.linting.pylintArgs": [
"--load-plugins=pylint_django",
"--errors-only"
],
}
Pylint——generate-rcfile是这样显示的:
[MESSAGES CONTROL]
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time.
#enable=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
#disable=
看起来就像~/。pylintrc在section [MESSAGES CONTROL]中应该有disable= line/s。
这是一个常见问题:
4.1 Is it possible to locally disable a particular message?
Yes, this feature has been added in Pylint 0.11. This may be done by
adding
# pylint: disable=some-message,another-one at the desired
block level or at the end of the desired line of code.
4.2 Is there a way to disable a message for a particular module only?
Yes, you can disable or enable (globally disabled) messages at the
module level by adding the corresponding option in a comment at the
top of the file:
# pylint: disable=wildcard-import, method-hidden
# pylint: enable=too-many-lines
您可以通过以下方式禁用消息:
数字编号:E1101, E1102等。
符号消息:无成员、未定义变量等。
一组检查的名称。你可以用pylint——list-groups来获取它们。
支票类别:C、R、W等。
所有人的支票。
请参阅文档(或在终端中运行pylint——list-msgs)以获得pylint消息的完整列表。文档还提供了如何使用该特性的很好的示例。