Skip to content

magic trailing comma not working in certain scenario #3239

@nipunn1313

Description

@nipunn1313

Describe the bug

Trailing commas are incorrectly being ruthlessly collapsed into one line

To Reproduce

Reproes in the black playground

def method(
    self,
) -> typing_extensions.Literal[
    "l1",
    "l2",
]: pass

Result is

def method(
    self,
) -> typing_extensions.Literal["l1", "l2",]:
    pass

Expected behavior

I'd expect no change to the Literal writeout.

Environment

Black 22.6.0 in the black playground.

Additional context

I noticed that if we eliminate the self argument, then black works correctly. Seems to have something to do with the fact that there are two trailing command in the method definition. Second one is not respected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions