[openstack-dev] [all] Update to flake8 and failures despite # flake8: noqa

Sean McGinnis sean.mcginnis at gmx.com
Fri Oct 26 18:22:58 UTC 2018


On Fri, Oct 26, 2018 at 12:53:17PM -0400, David Moreau Simard wrote:
> Hi openstack-dev,
> 
> I stumbled on odd and sudden pep8 failures with ARA recently and
> brought it up in #openstack-infra [1].
> 
> It was my understanding that appending "  # flake8: noqa" to a line of
> code would have flake8 ignore this line if it happened to violate any
> linting rules.
> It turns out that, at least according to the flake8 release notes [2],
> "flake8: noqa" is actually meant to ignore the linting on an entire
> file.
> 
> The correct way to ignore a specific line appears to be to append "  #
> noqa" to the line... without "flake8: ".
> Looking at codesearch [3], there is a lot of projects using the
> "flake8: noqa" approach with the intent of ignoring a specific line.
> 
> It would be important to fix that in order to make sure we're only
> ignoring the specific lines we're interested in ignoring and prevent
> upcoming failures in the jobs.
> 
> [1]: http://eavesdrop.openstack.org/irclogs/%23openstack-infra/%23openstack-infra.2018-10-26.log.html#t2018-10-26T16:18:38
> [2]: http://flake8.pycqa.org/en/latest/release-notes/3.6.0.html
> [3]: http://codesearch.openstack.org/?q=flake8%3A%20noqa&i=nope&files=&repos=
> 
> David Moreau Simard
> dmsimard = [irc, github, twitter]
> 

Thanks for raising this. We have a few of these in python-cinderclient, and
after correcting the usage, it was indeed suppressing some valid errors by
skipping the entire file.

For those looking at fixing this in your repos - this may help:

    for file in $(grep -r -l "flake8.*noqa" cinderclient/*); do
        sed -i 's/flake8.*noqa/noqa/g' $file
    done

Of course check the git diff and run any linting jobs before accepting the
changes from that.

Sean




More information about the OpenStack-dev mailing list