本文介绍了调用编程pylint的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调用pylint的检查,仅限于错误信号的一部分,作为我的单元测试的一部分。所以我查了pylint的可执行脚本,到了 pylint.lint.Run 辅助类,在那里我得到了在相当长 __ __的init 功能,通过调用结局 sys.exit()

I'd like to invoke the pylint checker, limited to the Error signalling part, as part of my unit testing. so I checked the pylint executable script, got to the pylint.lint.Run helper class and there I got lost in a quite long __init__ function, ending with a call to sys.exit().

有人曾经试图和管理,这样做呢?

anybody ever tried and managed to do so?

梦幻计划将是这样的:

if __name__ == '__main__':
  import pylint.lint
  pylint.lint.something(__file__, justerrors=True)
  # now continue with unit testing

任何提示?不是复制 __的init __ 方法和跳过 sys.exit(),我的意思吗?其他

any hints? other than "copy the __init__ method and skip the sys.exit()", I mean?

我不需要测试通过 pylint的运行,它也可能是 pyflakes 或其他软件:随时提出的替代品。谢谢!

I don't need the tests to be run by pylint, it might as well be pyflakes or other software: feel free to suggest alternatives. thanks!

推荐答案

看看在 pylint的/ epylint.py 包含的两个的不同的方法来编程启动pylint的。

Take a look at the pylint/epylint.py which contains two different ways to start pylint programatically.

您也可以直接电话咨询:

You can also simply call :

from pylint.lint import Run
Run(['--errors-only', 'myfile.py'])

例如

这篇关于调用编程pylint的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-12 01:05