I have a condition that reads like:
ok = (not a > 10 and
not b < 10 and
not c > 99 and
d == 99)
flake8 complains about this line with the error message:
W504 line break after binary operator
When I move the operator around, it throws a different error:
ok = (not a > 10
and not b < 10
and not c > 99
and d == 99)
W503 line break before binary operator
I tried multiple recommendations (e.g., this), but still, flake8 complains about the linebreak. The actual condition in my code is very long so I cannot put it in one line, also, it is the preference of my team to enclose long lines in () instead of using \.
W504orW503in your flake8 config, it's impossible to use both at the same time if you're not using `/`alleg:ok = all([not a > 10, not b < 10 ...]):. Secondly, anot conditional and not conditionalis the same asnot (conditional or conditional)according to De Morgan's Law . Without checking it, I suspect what's tripping up flake8 are the 2 binary operators. Why not tryany:ok = not any([a > 10, b < 10, ...])