简体   繁体   English

Python 黑色格式化程序与 VSCode 中的规则 flake8 W503 冲突

[英]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任何时候有内联断言规则要针对 bool 语句进行验证,在 VSCode 中使用 python black 格式化程序将中断该行,导致 flake8 警告规则 W503

line break before binary operatorflake8(W503)

assert (
      ...
      != ...
)

Is there any fix for this rather than ignoring that rule?有没有解决这个问题而不是忽略该规则?

you have set ignore = in your configuration -- you should use extend-ignore =你在你的配置中设置了ignore = -- 你应该使用extend-ignore =

W504 and W503 conflict with each other (and are both disabled by default) -- by setting ignore you've re-enabled them. W504W503相互冲突(并且默认情况下都被禁用)——通过设置ignore您已经重新启用它们。 extend-ignore does not have this problem as it augments the default set of ignored codes extend-ignore没有这个问题,因为它增加了默认的忽略代码集

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请注意,使用黑色时,您需要使用黑色的推荐设置: 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免责声明:我是当前的 flake8 维护者

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM