首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pylint不执行

Pylint不执行
EN

Stack Overflow用户
提问于 2020-09-01 00:22:28
回答 1查看 71关注 0票数 0

我有一个test.py文件,我想在带有转义重构(R)和约定(C)消息的checking.py文件中使用pylint进行检查。我做错了什么?

test.py

代码语言:javascript
复制
print("hello!")

checking.py

代码语言:javascript
复制
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选项时有拼写错误,但正如文档所说,我写得很好:

代码语言:javascript
复制
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.
EN

回答 1

Stack Overflow用户

发布于 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

代码语言:javascript
复制
[MESSAGES CONTROL]
disable=R,C

只需调用pylint test.py

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63674546

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档