是否可以从命令行运行PyCharm linter / code样式检查并获取警告/错误?
扩展到:是否有可能将其整合到我的Travis测试中?
将一些评论和一些进一步的研究放到答案中:
PyCharm附带了一个小命令行实用程序bin/inspect.sh
,记录了here。该工具虽然非常有限,但存在一些问题,例如: it cannot run while the PyCharm IDE is running和it reports somewhat incorrectly / different than the IDE。可以看到相关代码,例如here。
也许这些缺点可以在上游修复。参见例如this report,或this,或this。
我现在已经通过this script在Travis中使用它了。可以看到一个示例输出here。 (但正如所解释的,一些警告是不正确的,并且通常我得到的输出少于IDE。)
另外,我正在考虑编写一个扩展的简单实用程序,基本上这样做。所有的relevant PyCharm code is open source。我为此创建了一个项目页面pychar-inspect。但目前这只是在规划阶段,如果将在上游解决,可能会过时。