Search code examples
pythonflake8

flake8 to ignore warning F405 on multiple lines


I am having a fabric script and i am using below statement

from fabric.api import *

Now i know this isn't as per PEP8 standards but this is really needed specially for a library like fabric and we can really import everything from it. Because of this flake8 is complaining on multiple lines with F405 code.

I have disabled this for one line using #noqa but since there multiple lines with same PEP8 violation how can i ask flake8 to ignore this particular error code.

I have also tried # noqa: F405 at the beginning of the file but that didn't work.


Solution

  • Putting

    [flake8]
    ignore = E405
    

    in your .flake8 config file will work.

    Flake8 itself does not support per-file configuration, see the post: https://gitlab.com/pycqa/flake8/issues/156

    But for advanced configuration, e.g. per-file, recommended way is to use flake8-putty

    The homepage gives you an example:

    Disable only D102 on foo.py

    putty-ignore = foo.py : D102