Alex Tereshenkov
Alex Tereshenkov

Reputation: 3620

Flake8 - specify a range of errors to ignores?

flake8 supports specifying which error codes should be ignored, for instance:

per-file-ignores =
    setup.py:E121,E122,E123

However, I wonder whether it is possible to specify a range of errors in the form of E121-E130 so that all errors that fall within the range E121-E130 would be ignored (i.e. E122, E123, E124 and so forth up to E130). I am obviously able to produce a list of these errors code strings programmatically so I don't have to type each of them manually, but it kind of pollutes my setup.cfg file.

Is it something that flake8 supports?

Upvotes: 1

Views: 405

Answers (1)

Ian Stapleton Cordasco
Ian Stapleton Cordasco

Reputation: 28717

per-file-ignores supports the same syntax as the ignore option which is thoroughly documented.

In short, if you want to ignore all codes that start with E12 you can do

per-file-ignores =
    setup.py:E12

Keep in mind that will also ignore E120. There's no other "range" operator because we allow users to specify a prefix to match against and that fits the 99% use-case.

Upvotes: 3

Related Questions