[Python] Why does flake8 flag E226 only when whitespace is missing on both sides of operator?

Discussão em 'Python' iniciado por Stack, Agosto 30, 2025.

  1. Stack

    Stack Membro Participativo

    Here is a minimal reproducible example:

    j = 0*0 # Flagged for E226.
    j = 0* 0 # Not flagged for E226.
    j = 0 *0 # Not flagged for E226.


    As the comments suggest, flake8 flags only the first line, not the others, for E226:

    $ flake8 tmp.py --ignore=E225,E231,E117,F401,F811,F841,E303
    tmp.py:1:6: E226 missing whitespace around arithmetic operator


    But Flake8 rules require a space before and after:


    There should be one space before and after an arithmetic operator (+, -, /, and *).
    ​

    I installed and updated flake8 with pip:

    $ python3 -m pip install flake8 --upgrade


    Why does flake8 flag only the first line?

    Continue reading...

Compartilhe esta Página