Flake8: ignore special warning for whole file

The Ignore Errors docs currently indicate a way to ignore a specific error for a particular line:

example = lambda: 'example'  # noqa: E731

... and a way to ignore all errors for the whole file:

# flake8: noqa

from foo import unused
function_that_doesnt_exist()
x = 1+       2

... and in several ways, either through configuration or through command-line options, globally disable a specific error in the entire project.

But what if I want to ignore a specific error in an entire separate file - for example, turn off warnings about unused imports in a __init__.pyfile __init__.pythat simply imports several classes so that code from other packages can import them from this in turn? The docs don't seem to hint at any syntax for this. Is it possible?

+16
source share
2 answers

Ignoring certain errors was implemented only for individual lines, but not for individual files.

№ 89, . , .

, :

+13

Flake8 3.7.0 --per-file-ignores.

flake8 --per-file-ignores='project/__init__.py:F401 setup.py:E121'

per-file-ignores =
    project/__init__.py:F401
    setup.py:E121
    other_project/*:W9

: http://flake8.pycqa.org/en/latest/user/options.html?highlight=per-file-ignores#cmdoption-flake8-per-file-ignores

0

All Articles