Python black formatter conflict with rule flake8 W503 in VSCode
Asked Answered
A

1

13

Anytime there is an inline assertion rule to be verified against a bool statement, using the python black formatter in VSCode will break the line causing flake8 to warn about rule W503

line break before binary operatorflake8(W503)

assert (
      ...
      != ...
)

Is there any fix for this rather than ignoring that rule?

Alveolus answered 28/6, 2021 at 10:26 Comment(0)
V
41

you have set ignore = in your configuration -- you should use extend-ignore =

W504 and W503 conflict with each other (and are both disabled by default) -- by setting ignore you've re-enabled them. extend-ignore does not have this problem as it augments the default set of ignored codes

note that when working with black you'll want to use black's recommended settings: https://github.com/psf/black/blob/06ccb88bf2bd35a4dc5d591bb296b5b299d07323/docs/guides/using_black_with_other_tools.md#flake8

max-line-length = 88
extend-ignore = E203

disclaimer: I'm the current flake8 maintainer

Vagarious answered 29/6, 2021 at 3:8 Comment(3)
it also detects rule E501 and run the linter on the file doesn't solve itAlveolus
then add that to extend-ignore too (though the max-line-length is supposed to cover that)Vagarious
Ah! I was looking for answer why I keep seeing W503 even with the latest flake8/pycodestyle - and it was all about the fact that ignore setting resets the default ignore list, which W503 is in. Thanks!Malindamalinde

© 2022 - 2024 — McMap. All rights reserved.