Pylint 只显示警告和错误 [英] Pylint to show only warnings and errors

查看:48
本文介绍了Pylint 只显示警告和错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 pylint 检查我的代码,但我只对错误和警告级别感兴趣.有没有办法在命令行或 pylintrc 中做到这一点?

I would like to use pylint to check my code but I am only interested in error and warning levels. Is there a way to do that in command line or in pylintrc?

我对过滤给定的问题不感兴趣(比如在 MESSAGE CONTROL 中列出所有消息),我只是想让 pylint 忽略所有约定和重构消息.

I am not interested in filtering given issues (like listing all messages in MESSAGE CONTROL), I just want pylint to ignore all convention and refactor messages.

注意:我不认为这是 使用 Pylint 显示的重复错误和警告

推荐答案

使用 -d/--disable 选项关闭C"和R"" 消息类(约定和重构):

Use the -d / --disable option to turn off the "C" and "R" message classes (convention and refactor):

-d <msg ids>, --disable=<msg ids>
                    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"

如果没有 disable 选项(6 个约定,1 个重构,2 个警告,1 个错误):

Without the disable option (6 convention, 1 refactor, 2 warning, 1 error):

$ pylint x.py
C:  1, 0: Missing module docstring (missing-docstring)
C:  3, 0: Missing function docstring (missing-docstring)
R:  3, 0: Too many statements (775/50) (too-many-statements)
W:780,15: Redefining name 'path' from outer scope (line 796) (redefined-outer-name)
C:780, 0: Invalid function name "getSection" (invalid-name)
C:780, 0: Empty function docstring (empty-docstring)
C:782,23: Invalid variable name "inPath" (invalid-name)
W:785, 4: Statement seems to have no effect (pointless-statement)
E:785, 4: Undefined variable 'something' (undefined-variable)
C:796, 4: Invalid constant name "path" (invalid-name)

使用disable选项后(0个约定,0个重构,2个警告,1个错误):

After using the disable option (0 convention, 0 refactor, 2 warning, 1 error):

$ pylint --disable=R,C x.py
W:780,15: Redefining name 'path' from outer scope (line 796) (redefined-outer-name)
W:785, 4: Statement seems to have no effect (pointless-statement)
E:785, 4: Undefined variable 'something' (undefined-variable)

pylintrc中设置这个选项:

disable=R,C

这篇关于Pylint 只显示警告和错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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