Ignoring a specific flake8 rule for a folder
Question:
I am using flake8
, flake8-docstrings
and many other flake8
plugins in our project
I want to disable flake8-docstrings
only for our test
folder.
I want to avoid running flake8 twice because it would mean that running flake8 wouldn’t be the straight forward flake8 .
anymore. Not only that would mess with my ide settings, that would also be another excuse for the other developers in my project to not run flake8
.
Is there a way to configure flake8 to exclude specific rules just for a specific folder?
Answers:
There is not currently a native option for this.
There is a proposal to add support for this in the configuration file, though no current implementation exists.
There is flake8-per-file-ignores which is a plugin that accomplishes this feature
Update: per-file-ignores
has been included in core as of flake8 3.7.x
The easiest way to use it is in the configuration file:
[flake8]
per-file-ignores =
tests/*: D101
(disclaimer: I am the current flake8 maintainer)
have more complicated case when you need to ignore rule for ALL same named folders of a project
When you have a monorepo with several services and need to ignore a rule for for all files in all tests
folders accross the "globe"
this way not works:
per_file_ignores =
*/tests/*: S101
I am using flake8
, flake8-docstrings
and many other flake8
plugins in our project
I want to disable flake8-docstrings
only for our test
folder.
I want to avoid running flake8 twice because it would mean that running flake8 wouldn’t be the straight forward flake8 .
anymore. Not only that would mess with my ide settings, that would also be another excuse for the other developers in my project to not run flake8
.
Is there a way to configure flake8 to exclude specific rules just for a specific folder?
There is not currently a native option for this.
There is a proposal to add support for this in the configuration file, though no current implementation exists.
There is flake8-per-file-ignores which is a plugin that accomplishes this feature
Update: per-file-ignores
has been included in core as of flake8 3.7.x
The easiest way to use it is in the configuration file:
[flake8]
per-file-ignores =
tests/*: D101
(disclaimer: I am the current flake8 maintainer)
have more complicated case when you need to ignore rule for ALL same named folders of a project
When you have a monorepo with several services and need to ignore a rule for for all files in all tests
folders accross the "globe"
this way not works:
per_file_ignores =
*/tests/*: S101