[openstack-dev] migration to flake8

Monty Taylor mordred at inaugust.com
Thu Apr 4 16:49:47 UTC 2013


Hey all!

I was going to chat with folks about this at the summit, but it seems to
be gaining momentum anyway, so there may not be a lot of pushback.

Proposal:

Replace pep8 and pyflakes and pylint and hacking.py in our testing with
flake8

Rationale:

flake8 is the new pluggable hotness for this sort of thing. Out of the
box it runs pep8 and pyflakes. The combo of those two winds up being
very consistent and easy to deal with, so the extra goodness we get from
pylint isn't really needed anymore. pyflakes regularly catches actual
bugs for me, so rather than being just more style stuff, I'm pretty
pleased with it as a useful bit of testing. It's also totally possible
and easy to write pyflakes clean code.

flake8 supports reading options from tox.ini, which we already have in
our trees - even if you aren't using tox to run it. So we can set
project options easily (like ignore=E125) and just running flake8 from
the command line - or inside of vim/emacs - will work with the right
settings.

pyflakes issues show up prefixed by "F" and each one can be ignored now
just like with pep8.

flake8 also supports configurable additions to builtins, which lets us
deal with the normal pyflakes issue with how we do gettext.

I've also taken hacking.py from nova and turned it into a flake8 plugin,
which means we can use that without copying it around. The hacking
plugin is in openstack-dev/hacking in gerrit. If you install it, it will
inject into the flake8 workflow and show its errors prefixed with "H".

If there is a massive trainwreck on a line and pyflakes/hacking just
can't deal with reality, you can add a # noqa tag to the line and it'll
be skipped. We should probably be very limited in our usage of those.

End result: no need for wrapper scripts around pep8, pyflakes or pylint.
And a single, easy to deal with static-analysis check.

Several of the infra projects have switched already, Maru just put up a
quantum patch and I've got a ceilometer patch up for the switch. Patches
for everyone else should be super easy.

Thoughts?

Monty



More information about the OpenStack-dev mailing list