1

任何时候有一个内联断言规则要针对 bool 语句进行验证,在 VSCode 中使用 python black 格式化程序将打破导致 flake8 警告规则 W503 的行

line break before binary operatorflake8(W503)

assert (
      ...
      != ...
)

是否有任何解决方法而不是忽略该规则?

4

1 回答 1

5

你已经ignore =在你的配置中设置了——你应该使用extend-ignore =

W504并且W503相互冲突(并且默认情况下都被禁用) - 通过设置ignore您重新启用它们。extend-ignore没有这个问题,因为它增加了默认的忽略代码集

请注意,使用黑色时,您需要使用黑色的推荐设置:https ://github.com/psf/black/blob/06ccb88bf2bd35a4dc5d591bb296b5b299d07323/docs/guides/using_black_with_other_tools.md#flake8

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

免责声明:我是当前的 flake8 维护者

于 2021-06-29T03:08:28.117 回答