如何禁用 Pylint 警告? [英] How do I disable a Pylint warning?

查看:102
本文介绍了如何禁用 Pylint 警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试禁用警告 C0321(在一行上有多个语句"——我经常将带有短单行结果的 if 语句放在同一行中),在Pylint 0.21.1(如果重要的话:astng 0.20.1、common 0.50.3 和 Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)).

I'm trying to disable warning C0321 ("more than one statement on a single line" -- I often put if statements with short single-line results on the same line), in Pylint 0.21.1 (if it matters: astng 0.20.1, common 0.50.3, and Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)).

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

I've tried adding disable=C0321 in the Pylint configuration file, but Pylint insists on reporting it anyway. Variations on that line (like disable=0321 or disable=C321) are flagged as errors, so Pylint does recognize the option properly. It's just ignoring it.

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

Is this a Pylint bug, or am I doing something wrong? Is there a way around this?

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

I'd really like to get rid of some of this noise.

推荐答案

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 应该在 [MESSAGES CONTROL] 部分中包含 disable= 行.

So it looks like your ~/.pylintrc should have the disable= line/s in it inside a section [MESSAGES CONTROL].

这篇关于如何禁用 Pylint 警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆