Closed
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:
pass
A 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:
pass
Or maybe:
def foo(
x:
Loooooooooooooooooooooooong
| Looooooooooooooooong
| Looooooooooooooooooooong
| Looooooong,
) -> None:
pass
Or:
def foo(
x: Loooooooooooooooooooooooong
| Looooooooooooooooong
| Looooooooooooooooooooong
| Looooooong,
) -> None:
pass
Activity