Flake8

Flake8 runs all tools by launching the single 'flake8' script, but ignores pep8
and PyFlakes extended options and just uses defaults. It displays the warnings
in a per-file, merged output.

It also adds a few features:

files that contains with this header are skipped:

# flake8: noqa

lines that contain a "# NOQA" comment at the end will not issue pyflakes
warnings.

lines that contain a "# NOPEP8" comment at the end will not issue pep8
warnings.

a Mercurial hook.

a McCabe complexity checker.

QuickStart

To run flake8 just invoke it against any directory or Python module:

$ flake8 coolproject
coolproject/mod.py:1027: local variable 'errors' is assigned to but never used
coolproject/mod.py:97: 'shutil' imported but unused
coolproject/mod.py:729: redefinition of function 'readlines' from line 723
coolproject/mod.py:1028: local variable 'errors' is assigned to but never used
coolproject/mod.py:625:17: E225 missing whitespace around operato

The output of PyFlakes and pep8 is merged and returned.

flake8 offers an extra option: --max-complexity, which will emit a warning if the
McCabe complexityu of a function is higher that the value. By default it's
deactivated:

If strict option is set to True, any warning will block the commit. When
strict is set to False or omited, warnings are just displayed in the
standard output.

complexity defines the maximum McCabe complexity allowed before a warning
is emited. If you don't specify it or set it to -1, it's just ignored.
If specified, it must be a positive value. 12 is usually a good value.

lazy when set to True will also take into account files not added to the
index.

Also, make sure the file is executable and adapt the shebang line so it
point to your python interpreter.

Buildout integration

In order to use Flake8 inside a buildout, edit your buildout.cfg and add this: