Skip to content

Wrapping lines of a function signature that uses the new python 3.12 generic type parameter syntax #4071

@Questionsdenombres

Description

@Questionsdenombres

Context:

def func(a: int, b: int) -> int:
    return a + b 

def func(
    a: int,
    b: int,
) -> int:
    return a + b

python 3.12 new feature:

def func[T](a: T, b: T) -> T:
    return a

Example in the current Black style:
Enforcing black to wrap lines gives the ugly:

def func[
    T
](a: T, b: T,) -> T:
    return a

Desired style:

def func[T](
    a: T,
    b: T,
) -> T:
    return a + b

Additional context
python==3.12
black==23.11.0
Windows==11
VScode==1.84.2
VScode extension! Black Formatter==v2023.6.0

Credits:
Thank you for your great tool.
Patrick, Paris, France.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: linebreakHow should we split up lines?S: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedT: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions