【发布时间】:2018-06-28 12:36:35
【问题描述】:
我正在尝试在 python 程序中使用pycodestyle:
from pycodestyle import StyleGuide, StandardReport
CONFIG_FILE = 'setup.cfg'
def check_pycodestyle():
style_guide = StyleGuide(config_file=CONFIG_FILE, quiet=True)
# style_guide = StyleGuide(config_file=CONFIG_FILE, reporter=StandardReport, quiet=True)
report = style_guide.check_files(paths='./')
不幸的是,我还没有找到将结果作为简单返回值的方法。使用quiet=True 标志时,不会自动打印任何内容,但返回的报告是BaseReport,似乎不包含实际结果,而只是计算total_errors 的数量。
当省略quiet 标志时,会自动打印结果。
是否有检索结果而不打印结果的功能?
编辑:
使用report.get_file_results() 时,我收到以下结果:
与quiet=True:
0
没有quiet:
<prints the results>
0
【问题讨论】:
-
举一个
report.get_file_results()返回的例子 -
我添加了输出
标签: python pycodestyle