Skip to content

Inconsistent formatting of match-case on [] and _ #17969

Open
@adamchainz

Description

@adamchainz

Summary

Playground link

Source:

a = []
b = []
match a, b:
    case [], []:
        ...
    case [], _:
        ...
    case _, []:
        ...
    case _, _:
        ...

Formatted:

a = []
b = []
match a, b:
    case [[], []]:
        ...
    case [[], _]:
        ...
    case _, []:
        ...
    case _, _:
        ...

It seems rather inconsistent that the formatter adds wrapping [] on the first two cases but not the others.

Edit: for reference, Black leaves the original file unchanged.

Version

ruff 0.11.7 (f7b4851 2025-04-24)

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formatterstyleHow should formatted code look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions