Skip to content

Add magic-trailing-comma newline to function definition and call. #3093

@synchronizing

Description

@synchronizing

The latest release, 22.3.0, issue #2918, PR #2942, has broken formatting for function definition and call. In previous versions of Black the following:

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

def intentional_comma(a: int, b: int, c: int,):
    return a + b + c

intentional_comma(a=10, b=20, c=30,)

Would be formatted to:

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

def intentional_comma(
    a: int, 
    b: int, 
    c: int,
):
    return a + b + c

intentional_comma(
    a=10, 
    b=20, 
    c=30,
)

But the new versioning breaks this, and the above is now formatted as:

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

def intentional_comma(
    a: int, b: int, c: int,
):
    return a + b + c

intentional_comma(
    a=10, b=20, c=30,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    R: invalidThis issue / pull request doesn't seem right
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions