Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring a specific flake8 rule for a folder

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?

like image 495
tibo Avatar asked Oct 22 '18 07:10

tibo


1 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)

like image 95
Anthony Sottile Avatar answered Oct 27 '22 00:10

Anthony Sottile