Linting in Python

I found a nice list of Python linting tools on SO here. I’d recommend using these as a sanity-check before running nosetests. The two I like the best are pylint and flake8.

pylint

I use the --disable=C flag to suppress convention suggestions. I like putting spaces around arguments in functions, and this makes the convention messages blow up.

pylint --disable=C program.py

flake8

Flake8 wraps two other linters, pep8 and pyflakes. It will also blow up on convention suggestions, but you can figure out which things it doesn’t like and suppress them with the --ignore= flag like so,

flake8 --ignore=E201,E202 program.py