test suite does not work with flake8 3.x

Bug #1652411 reported by Adam Williamson
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
hacking
New
Undecided
Unassigned

Bug Description

hacking's test suite does not work with flake8 3.x. It tries to run checks by getting a styleguide from flake8 and using its options to initialize a report and a checker from pep8 (pycodestyle). flake8 3.x just doesn't really work for that approach any more; even if you adjust to use its 'legacy api', its imitation of a styleguide instance doesn't actually have sufficient data to convince a pep8 checker to run the right checks.

Fortunately, there's a different approach we can use which is actually simpler and works for both 2.x and 3.x; we just use the styleguide directly to run the tests. 3.x's 'legacy API' *does* work for this, as that's what it's explicitly intended to work for, per http://flake8.pycqa.org/en/latest/user/python-api.html . I've written a patch which does this, and tested that it works with both flake8 3.2.1 and flake8 2.5.5.

The test_local.test_local_check test still fails on flake8 3.x. This is because, well, that feature doesn't work on flake8 3.x at all. See https://bugs.launchpad.net/hacking/+bug/1652409 for more details on that.

I'm gonna stick my patch here for now as I'm just too tired to jump through the zillions of hoops required to submit it 'properly'. I work for Red Hat, so it may be the case that I don't have to / am not allowed to join and sign the CLA as an individual. I'll see what RH's OpenStack people advise me to do later, I guess. For now, here's what I got.

Revision history for this message
Adam Williamson (awilliamson) wrote :
Revision history for this message
Adam Williamson (awilliamson) wrote :

oh, in case you're wondering why the temporary files are necessary - the flake8 3.x API does not provide any ability to run tests on an iterable of lines. It only gives you `check_files` (which requires an iterable of file names) and `input_file` (which has a 'lines' arg, but completely ignores it - it really just takes the filename and feeds it to `check_files`).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.