Search code examples
pythontextmatepylint

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. I installed pycheckmate, pylint, and created a .pylintrc file in $HOME that sets the output format to html.

In TextMate's Advanced control panel, in the Shell Variables tab, I have TM_PYCHECKER set to /usr/local/share/python/pylint. If I trigger Validate Syntax, it runs pylint with all the default options, and gives me the output. If I change TM_PYCHECKER to /usr/local/share/python/pylint --rcfile "$HOME/.pylintrc" and Validate Syntax again, I get:

Please install PyChecker, PyFlakes or Pylint for more extensive code checking.

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. What am I missing?


Solution

  • OK, I think I found the problem: pycheckmate sets --output-format=parseable' as a forced argument to pylint. I found this out by replacing /usr/local/share/python/pylint with a wrapper script that printed out its arguments:

    #!/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:

    ['--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. Sure enough, it adds that argument, as well as a whole lot of hard-coded 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.