Skip to content

Preserve pattern parentheses #6753

@MichaReiser

Description

@MichaReiser

Black seems to preserve parentheses around nested patterns.

match a:
    case [(*rest), (a as b)]:
        print("test")
    
    case (a): pass

This is in line with Black preserving parentheses around nested expressions.

Surprisingly, Black also seems to preserve parentheses around top-level patterns. I would be okay diverging from Black to align with the Expression formatting.

Metadata

Metadata

Assignees

Labels

formatterRelated to the formatter

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions