Code and style checks for Python at Sublime Text

As now I'm coding with Python (and learning it), here comes a similar post as the one I did for Ruby but adapted. Basically I want to centralize my coding to use if possible just one IDE for every language and file, so while probably PyCharm is better (as usually JetBrains tools are awesome) I get more flexibility with Sublime Text. Here are the specific packages I use:

  • Package Control: Plugin/package manager, required for the other components
  • SublimeLinter 3: Generic text linter for the editor. Required for the specific linters
  • PEP8 (Style guide for Python coding): pip install pep8
  • SublimeLinter-PEP8: To have the PEP8 rules inside the editor
  • MyPy (Static type checker): pip install mypy
  • SublimeLinter-contrib-mypy: To have the MyPy rules inside the editor (might conflict with PEP8 ones)

Despite having a tox.ini pep8 configuration file, if you see Sublime ignoring you, you can force some configuration settings for any linter going to:

Preferences -> Package Settings -> SublimeLinter -> Settings – User

And then adding custom rules under the pep8 section, e.g.:

"pep8": {
"max-line-length": 120
}

For additional, more strict rules, I use:

  • Flake8 (another source code checker): pip install flake8
  • SublimeLinter-Flake8: Again, to integrate with Sublime
  • Flake8Lint: I'm still comparing with previous one to see if I need both or just this one, but this is quite powerful and configurable, so definetly a must

And that's all for now, if I add more interesting packages I'll update the post, and of course comments and suggestions are welcome.

Comments?

Posted by Kartones on 2016-01-01