Python:黑色不会换行

问题描述

我正在使用<Meta name="viewport" content="width=device-width,initial-scale=1">

我有一个长字符串,如:

black==20.8b1

我跑步:

return f"{self.name},a {adjective.to_name()} {kin_string}{self._type.to_name()} who works for the {target.get_relationship_target_string()}."

为什么不包装字符串?我认为$ black -l 80 . -t py38 All done! ✨ ? ✨ 2 files left unchanged. 现在支持包装字符串(基于github中的问题)。

解决方法

当前,Black不会包装长字符串或长注释。您会看到open issue in their project GitHub的话:

Black当前不包装长字符串文字或合并碰巧在同一行上的字符串文字。 [...]这将需要修改AST,它不是100%安全的,并且要处理很多边缘情况。

,

当前,我们必须向其中添加--experimental-string-processing标签。我认为是future versions it will be made default

black -l 80 --experimental-string-processing file.py