Python black formatter conflict with rule flake8 W503 in VSCode

Viewed 4798

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?

1 Answers

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

Related