Flake8 disable all formatting rules
Asked Answered
S

2

18

I use flake8 for linting and black for formatting.

flake8 produces warnings on execution rules and formatting rules:

enter image description here

I only want to see execution rules. I don't care about formatting rules because they'll automatically get fixed by black formatting:

enter image description here

I can disable these rules one at a time by running flake8 --ignore=E271,E225,W291,E231. However, there's no exhaustive list of formatting rules to disable, they have to be discovered one at a time. It would be great to have something similar to JavaScript's eslint, where there's a plugin to disable all formatting rules that are covered by the code formatter.

Is there a similar way to disable all the formatting rules in flake8?

Solution: Based on the below answer, I ended up ignoring all formatting rules with this command:

flake8 --ignore=E101,E111,E114,E115,E116,E117,E12,E13,E2,E3,E401,E5,E70,W1,W2,W3,W5 file.py
Samarium answered 8/12, 2019 at 23:56 Comment(0)
I
7

I also wanted to disable aesthetic errors. I came up with a slightly different list of what to ignore; this is what I have in my setup.cfg.

[flake8]
extend-ignore =
    # Indentation — black handles
    E1
    W1
    # Whitespace — black handles
    E2
    W2
    # Blank lines — black handles
    E3
    W3
    # Imports — isort handles
    E4
    W4
    # Line length — black handles
    E5
    W5
    # No lambdas — too strict
    E731
Inviting answered 30/9, 2021 at 17:1 Comment(0)
M
3

It looks like you can ignore by error code pattern, not just specific error codes, e.g. --ignore=E1,W for all error codes beginning with E1 and W. Here's a list of current error codes you can use to specify the kind of errors you'd like to ignore.

Meetly answered 10/12, 2019 at 14:28 Comment(1)
Thanks for the list of errors. I went through the list and updated the original question with a list of all the warnings I can safely ignore.Samarium

© 2022 - 2024 — McMap. All rights reserved.