Reputation: 57391
I'm editing a Django settings file that looks similar to the following:
# flake8: noqa
from lucy.settings.base import *
from lucy.settings.staging_production import *
# This ensures that errors from staging are tagged accordingly in Airbrake's console
AIRBRAKE.update(environment='staging')
LOGGING['handlers'].update(console={
'class': 'logging.StreamHandler'
})
This setting lucy/settings/staging.py
, extends two other ones and I'd like to keep the 'star imports', so I'd like to ignore error codes E403
and E405
for this file.
However, the only way I see to do that is to add the #noqa: E403, E405
comment to every line that it applies; by writing # flake8: noqa
at the top of the file, it ignores all errors.
As far as I can tell from http://flake8.pycqa.org/en/3.1.1/user/ignoring-errors.html, it isn't possible to do this, or have I overlooked something?
Upvotes: 7
Views: 3581
Reputation: 149736
Starting with Flake8 3.7.0, you can ignore specific warnings for entire files using the --per-file-ignores
option.
Command-line usage:
flake8 --per-file-ignores='project/__init__.py:F401,F403 setup.py:E121'
This can also be specified in a config file:
[flake8]
per-file-ignores =
__init__.py: F401,F403
setup.py: E121
other/*: W9
Upvotes: 8
Reputation: 2478
There is no way of specifying that in the file itself, as far as I'm concerned - but you can ignore these errors when triggering flake:
flake8 --ignore=E403,E405 lucy/settings/staging.py
Upvotes: 0