Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python black formatter conflict with rule flake8 W503 in VSCode

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?

like image 658
Antonio Santoro Avatar asked Jan 31 '26 22:01

Antonio Santoro


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

like image 139
Anthony Sottile Avatar answered Feb 03 '26 11:02

Anthony Sottile



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!