-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
F: linebreakHow should we split up lines?How should we split up lines?F: parenthesesToo many parentheses, not enough parentheses, and so on.Too many parentheses, not enough parentheses, and so on.T: styleWhat do we want Blackened code to look like?What do we want Blackened code to look like?
Milestone
Description
Describe the style change
Long PEP 604 annotations (X | Y) in function definitions (and probably other contexts) are currently broken into multiple lines without extra indentation. This makes it hard to recognize the arguments in the signature. My suggestion would be to treat those annotations similar to regular bitwise or operators inside type annotations: Indent followup lines and possibly use parentheses.
Examples in the current Black style
def foo(
i: int,
x: Loooooooooooooooooooooooong
| Looooooooooooooooong
| Looooooooooooooooooooong
| Looooooong,
*,
s: str
) -> None:
passA practical example (with shorter line width):
def create_medical_record_entries(
context: RequestContext,
db_entries: Iterable[CharlyMedicalRecordEntry]
| Iterable[CharlyLabRecordEntry],
*,
ignore_signs: bool = True
) -> list[MedicalRecordEntry]:
...Desired style (without extra arguments)
def foo(
x: (
Loooooooooooooooooooooooong
| Looooooooooooooooong
| Looooooooooooooooooooong
| Looooooong
),
) -> None:
passOr maybe:
def foo(
x:
Loooooooooooooooooooooooong
| Looooooooooooooooong
| Looooooooooooooooooooong
| Looooooong,
) -> None:
passOr:
def foo(
x: Loooooooooooooooooooooooong
| Looooooooooooooooong
| Looooooooooooooooooooong
| Looooooong,
) -> None:
passReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
F: linebreakHow should we split up lines?How should we split up lines?F: parenthesesToo many parentheses, not enough parentheses, and so on.Too many parentheses, not enough parentheses, and so on.T: styleWhat do we want Blackened code to look like?What do we want Blackened code to look like?