[devel] Fast flake8 testing

Zane Bitter zbitter at redhat.com
Thu Jun 20 17:37:19 UTC 2019

Those of you who work on a fairly large project will have noticed that 
running flake8 over all of it takes some time, and that this slows down 

Nova (at least) has a solution to this, in the form of a "fast8" tox 
environment that runs flake8 only against the files that have changed in 
the latest patch + the working directory. This is *much* faster, but 
that approach has some limitations: the script is buggy, it only tests 
the top-most patch, it creates a second tox environment (which is slow) 
that can then get out of sync with your regular pep8 environment, and of 
course it requires the project to add it explicitly.

If you're interested in a solution with none of those limitations, here 
is a script that I've been using:


It tests all changes on the branch, using your existing pep8 tox 
environment, handles deleted files and changes to non-python files 
correctly, and should be usable for every OpenStack project.

I hope this is helpful to someone.

(Note that the pep8 environment on many projects includes other test 
commands in addition to flake8 - such as bandit - so you should still 
run the pep8 tox tests once before submitting a patch.)


More information about the openstack-discuss mailing list