[devel] Fast flake8 testing

Stephen Finucane sfinucan at redhat.com
Fri Jun 21 16:47:05 UTC 2019

On Thu, 2019-06-20 at 13:37 -0400, Zane Bitter wrote:
> 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 
> development.
> 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:
> https://gist.github.com/zaneb/7a8c752bfd97dd8972756d296fc5e41f

Neat :) There's also the opportunity of integrating flake8 (and other
things) as a pre-commit hook, which is something I'm trying to adopt
within nova and the maybe oslo and further over time.


That requires some project-level work though (including backports, if
you want it on stable branches) whereas your script can be used
anywhere. Both useful.


> 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.)
> cheers,
> Zane.

More information about the openstack-discuss mailing list