flake8: Ignore only F401 rule in entire file

According to the Documentation it's as easy as changing # noqa by:

# noqa: F401

there is not currently a way to do what you're asking with only source inside the file itself

the current suggested way is to use the per-file-ignores feature in your flake8 configuration:

[flake8]
per-file-ignores =
    */__init__.py: F401

Note that F401 in particular can be solved in a better way, any names that are exposed in __all__ will be ignored by pyflakes:

from foo import bar  # would potentially trigger F401
__all__ = ('bar',)  # not any more!

(disclaimer: I'm the current maintainer of flake8 and one of the maintainers of pyflakes)

Tags:

Python

Flake8