我有一个test.py文件,我想在带有转义重构(R)和约定(C)消息的checking.py文件中使用pylint进行检查。我做错了什么?
test.py
print("hello!")checking.py
import pylint.lint
from pylint import epylint as lint
pylint_opts = ['--disable=R,C']
pylint.lint.Run(pylint_opts)
(pylint_stdout, pylint_stderr) = lint.py_run('test.py', return_std=True)它返回帮助消息,假设我在编写pylint选项时有拼写错误,但正如文档所说,我写得很好:
Messages control
-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".
There are 5 kind of message types :
* (C) convention, for programming standard violation
* (R) refactor, for bad code smell
* (W) warning, for python specific problems
* (E) error, for probable bugs in the code
* (F) fatal, if an error occurred which prevented pylint from doing
further processing.发布于 2020-09-01 00:51:42
epylint()使用sys.argv做自己的initialisation (调用Run),即。调用checking.py时使用的参数
我猜你只是在调用python checking.py,所以sys.argv[1:] == [],这意味着在bash中,你将执行pylint (带任何参数)。
我认为你的解决方案过于复杂了。为什么不在命令行上调用pylint --disable R,C test.py呢?
你甚至可以写一个.pylintrc:
[MESSAGES CONTROL]
disable=R,C只需调用pylint test.py
https://stackoverflow.com/questions/63674546
复制相似问题