Avoid needless linebreaks on |
in PEP-604 type annotations
#3319
Labels
F: linebreak
How should we split up lines?
R: duplicate
This issue or pull request already exists
T: style
What do we want Blackened code to look like?
Describe the style change
Given the increasing popularity of Python 3.10 and PEP604 type annotations (
arg: X | Y
), it's unfortunate that Black is so eager to put linebreaks in the middle. This happens when it's not necessary to meet line-length limits; and also when splitting doesn't achieve line-length limits!I propose that the
|
operator be treated as binding more tightly in type annotations, to make Python 3.10+ code more elegant.Examples in the current Black style
Lines beginning
| None =
are all too common, and I'll admit that I don't like them at all. Instead, I think that we should keep annotations on a single line where possible (or parenthesized where not, instead of split out to a term per line).Desired style
Notably I think it's important to ship this before freezing the 2023 code style, preferably with enough time for a round of feedback from
--preview
users.The text was updated successfully, but these errors were encountered: