AnthropocentricAI Artificial Intelligence for Humans

Python Linting Software

2018-09-24
Matt Clifford

Linting software for python.

Pylint vs Flake8

The two most popular linting programmes for python are flake8 and pylint. Flake8 focuses on PEP8, whereas pylint has a larger warning set, appearing to be almost a superset of flake8. However both flake8 and pylint support plugins, with the ability to create your own plugins. Flake8 runs slightly faster than pylint, but nothing noticeable on small to medium projects. Both also have the ability to use multiple processes too.

When ignoring a line of code in flake8 or pylint using the inline comment # noqa excludes any variables from static analysis in flake8, but pylint doesn’t.

Pylint seems to be more widely used than flake8, due to its more rigourous testing. However there is no harm in running both, which is a popular choice for most developers. Continuous integration makes this very simple to implement also.

Continuous Integration vs Landscape

Landspace is a website that automatically lints code on each git push, using pylint as its default linter. It formats the results into a nice GUI. However, landscape’s website seems to be very buggy, with their documentation broken and more importantly none of the testing works. After running this error message is given:

Check number # has failed. This is almost always due to a bug in Landscape - we have been notified. Sorry about that.

Failure reason: Unknown

We don't know exactly why this error happened yet

It is probably best to stay clear of landscape since the CI implementation is simple and robust, although lacking the extra readability and tracking that landscapes would have provided. One thing to note with CI is that if the linting exits with a warning or error code this will fail the CI build. This could be beneficial as all code needs to be up to linting standards on every push, but a hindrance if not. Errors and warnings can always be ignored in the configuration file though.


Content