Skip to content

Integration of pep8 and pyflakes checkers for python files in SublimeText 2 editor (Linux/MacOSX only)

Notifications You must be signed in to change notification settings

gcarvalho/sublimetext_python_checker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python PEP-8 and PyFlakes checker for SublimeText editor (2 and 3)

This project is a plugin for SublimeText 2 text editor. It checks all python files you opening and editing through two popular Python checkers - pep8 and PyFlakes.

Installation

Go to your Packages dir (Sublime Text 2 -> Preferences -> Browse Packages). Clone this repository into Packages subdirectory:

git clone git://github.com/vorushin/sublimetext_python_checker.git

Go to sublimetext_python_checker/ and create file local_settings.py with list of your preferred checkers:

    CHECKERS = [('/Users/vorushin/.virtualenvs/checkers/bin/pep8', [], False),
                ('/Users/vorushin/.virtualenvs/checkers/bin/pyflakes', [], False)]

First parameter is path to command. Second - optional list of arguments, If you want to disable line length checking in pep8, set second parameter to ['--ignore=E501']. third - do you want to run this checker on each change. Only works with pyflakes, ATM.

You can also set syntax checkers using sublimetext settings (per file, global, per project, ...):

    "settings":
    {
        "python_syntax_checkers":
        [
            ["/usr/bin/pep8", ["--ignore=E501,E128,E221"] ]
        ],
        false
    }

Both "CHECKERS local_settings" and sublime text settings will be used, but sublime text settings are prefered. (using syntax checker binary name)

Restart SublimeText 2 and open some *.py file to see check results. You can see additional information in python console of your editor (go View -> Show Console).

You can also set the colloring of the highlights generated by the plugin. By default it will use the color for "keyword" (for pep8 messages) and "invalid" (for pyflakes messages). You can customise it by using the specific strings, though: keyword.python_checker.outline: outline around lines with pep8 flags invalid.python_checker.outline: outline around lines with pyflakes flags keyword.python_checker.underline: column-specific mark for flags which provide it

An example used with a Solarized theme:

    <dict>
        <key>name</key>
        <string>invalid.python_checker.outline</string>
        <key>scope</key>
        <string>invalid.python_checker.outline</string>
        <key>settings</key>
        <dict>
            <key>background</key>
            <string>#FF4A52</string>
            <key>foreground</key>
            <string>#FFFFFF</string>
        </dict>
    </dict>
    <dict>
        <key>name</key>
        <string>keyword.python_checker.outline</string>
        <key>scope</key>
        <string>keyword.python_checker.outline</string>
        <key>settings</key>
        <dict>
            <key>background</key>
            <string>#DF9400</string>
            <key>foreground</key>
            <string>#FFFFFF</string>
        </dict>
    </dict>
    <dict>
        <key>name</key>
        <string>keyword.python_checker.underline</string>
        <key>scope</key>
        <string>keyword.python_checker.underline</string>
        <key>settings</key>
        <dict>
            <key>background</key>
            <string>#FF0000</string>
        </dict>
    </dict>

Why not sublimelint

Before creating this project I used sublimelint, which is multilanguage checker/linter. I described pros and cons of both below.

sublimelint

  • can't use your Python version or your virtualenv
  • don't check with pep8
  • do checks on every edit
  • do checks for Python (derivative of pyflakes), PHP, Perl, Ruby
  • works on Windows/Linux/MacOSX

sublimetext_python_checker

  • can use your version of Python and your virtualenv
  • do checks only on opening and saving files
  • works only on Linux and Mac OS X
  • checks only Python files
  • checks with pep8 and pyflakes
  • all this in a few screens of code

About

Integration of pep8 and pyflakes checkers for python files in SublimeText 2 editor (Linux/MacOSX only)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%