如何禁用 Pylint 警告?

新手上路,请多包涵

我正在尝试在 if 0.21.1(如果重要:astng 0.20.1、common 0.50.3 和 Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56))。

我尝试在 Pylint 配置文件中添加 disable=C0321 ,但 Pylint 仍然坚持要报告它。该行的变化(如 disable=0321disable=C321 )被标记为错误,因此 Pylint 确实 可以正确识别该选项。它只是忽略它。

这是一个 Pylint 错误,还是我做错了什么?有没有解决的办法?

我真的很想摆脱一些这种噪音。

原文由 Head Geek 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 2k
2 个回答

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 应该有 disable= line/s 在一个部分 [MESSAGES CONTROL]

原文由 Chris Morgan 发布,翻译遵循 CC BY-SA 2.5 许可协议

从 Pylint v. 0.25.3 开始,您可以使用符号名称来禁用警告 ,而不必记住所有这些代码数字。例如:

 # pylint: disable=locally-disabled, multiple-statements, fixme, line-too-long

这种风格比神秘的错误代码更有指导意义,也更实用,因为新版本的 Pylint 只输出符号名称,而不是错误代码。

符号名称和代码的对应关系可以在 这里 找到。

可以在其自己的行中插入禁用注释,将禁用应用于同一块中之后的所有内容。或者,它可以插入到它要应用的行的末尾。

如果 Pylint 输出“ Locally disabling ”消息,您可以通过禁用 locally-disabled 摆脱它们,如上例所示。

原文由 imolit 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题