简体   繁体   English

从TextMate运行时pylint忽略.pylintrc

[英]pylint ignores .pylintrc when run from TextMate

I'm trying to get pylint to give html output when I run Validate syntax on a python file in TextMate. 当我在TextMate中的python文件上运行Validate语法时,我试图让pylint提供html输出。 I installed pycheckmate, pylint, and created a .pylintrc file in $HOME that sets the output format to html. 我安装了pycheckmate,pylint,并在$ HOME中创建了一个.pylintrc文件,该文件将输出格式设置为html。

In TextMate's Advanced control panel, in the Shell Variables tab, I have TM_PYCHECKER set to /usr/local/share/python/pylint . 在TextMate的“高级”控制面板中,在“ Shell变量”选项卡中,我将TM_PYCHECKER设置为/usr/local/share/python/pylint If I trigger Validate Syntax, it runs pylint with all the default options, and gives me the output. 如果我触发“验证语法”,它将使用所有默认选项运行pylint,并提供输出。 If I change TM_PYCHECKER to /usr/local/share/python/pylint --rcfile "$HOME/.pylintrc" and Validate Syntax again, I get: 如果我将TM_PYCHECKER更改为/usr/local/share/python/pylint --rcfile "$HOME/.pylintrc"并再次验证语法, /usr/local/share/python/pylint --rcfile "$HOME/.pylintrc"得到:

Please install PyChecker, PyFlakes or Pylint for more extensive code checking. 请安装PyChecker,PyFlakes或Pylint以进行更广泛的代码检查。

If I run /usr/local/share/python/pylint from the commandline, without any arguments, the output is html, so I know in that case that it's reading the rcfile. 如果我从命令行运行/ usr / local / share / python / pylint,不带任何参数,则输出为html,因此在这种情况下,我知道它正在读取rcfile。 What am I missing? 我想念什么?

OK, I think I found the problem: pycheckmate sets --output-format=parseable' as a forced argument to pylint. 好的,我想我发现了问题:pycheckmate将--output-format=parseable' parseable设置为pylint的强制参数。 I found this out by replacing /usr/local/share/python/pylint with a wrapper script that printed out its arguments: 我通过用输出其参数的包装脚本替换/ usr / local / share / python / pylint来发现这一点:

#!/usr/bin/env python

import sys
from pylint import lint

print sys.argv[1:]
lint.Run(sys.argv[1:])

And when I ran it in TextMate I saw this: 当我在TextMate中运行它时,我看到了:

['--output-format=parseable', '/Users/smithm5/test.py']
test.py:26 [C] Line too long (90/80)
…

So I dug into /Applications/TextMate.app/Contents/SharedSupport/Bundles/Python.tmbundle/Support/bin/pycheckmate.py itself. 因此,我自己浏览了/Applications/TextMate.app/Contents/SharedSupport/Bundles/Python.tmbundle/Support/bin/pycheckmate.py本身。 Sure enough, it adds that argument, as well as a whole lot of hard-coded html. 当然,它添加了该参数以及大量的硬编码html。 So to fix it, I removed all the escape() wrappers, set opts = () on line 287 so I could set my own darn opts, and changed line 332 to print line . 因此,要解决此问题,我删除了所有的escape()包装器,在第287行设置opts = () ,以便可以设置自己的织补选项,并将第332 print line更改为print line

A somewhat educated guess: try replacing $HOME by the absolute path to your home directory. 一个有根据的猜测:尝试用主目录的绝对路径替换$HOME Shell variables like $HOME are probably not available to use in TextMate's control panel. 诸如$HOME类的Shell变量可能无法在TextMate的控制面板中使用。

UPDATE: Looking at the pycheckmate.py script included with the Python.tmbundle included with the version of TextMate I have, it appears that it is not possible to include arguments , like --rcfile /path/to/rcfile . 更新:查看我拥有的TextMate版本随附的Python.tmbundle附带的pycheckmate.py脚本,看来不可能包含--rcfile /path/to/rcfile The value of TM_PYCHECKER is expected to only be the path to the checker binary with no arguments. 预期TM_PYCHECKER的值仅是没有参数的检查程序二进制文件的路径。 But, if you make your own copy of the Python.tmbundle, you should be able to edit pycheckmate.py to do as you wish. 但是,如果您制作自己的Python.tmbundle副本,则应该能够编辑pycheckmate.py以执行您想要的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM