black/tests/data/cases/remove_redundant_parens_in_case_guard.py
Logan Hunt dab37a6a11
Remove redundant parentheses in case statement if guards (#4214)
A follow up to #4024 but for `if` guards in `case` statements. I noticed this
when #4024 was made stable, and noticed I had some code that had extra parens
around the `if` guard.
2024-02-07 06:55:02 -08:00

115 lines
1.5 KiB
Python

# flags: --minimum-version=3.10 --preview --line-length=79
match 1:
case _ if (True):
pass
match 1:
case _ if (
True
):
pass
match 1:
case _ if (
# this is a comment
True
):
pass
match 1:
case _ if (
True
# this is a comment
):
pass
match 1:
case _ if (
True # this is a comment
):
pass
match 1:
case _ if ( # this is a comment
True
):
pass
match 1:
case _ if (
True
): # this is a comment
pass
match 1:
case _ if (True): # comment over the line limit unless parens are removed x
pass
match 1:
case _ if (True): # comment over the line limit and parens should go to next line
pass
# output
match 1:
case _ if True:
pass
match 1:
case _ if True:
pass
match 1:
case _ if (
# this is a comment
True
):
pass
match 1:
case _ if (
True
# this is a comment
):
pass
match 1:
case _ if True: # this is a comment
pass
match 1:
case _ if True: # this is a comment
pass
match 1:
case _ if True: # this is a comment
pass
match 1:
case _ if True: # comment over the line limit unless parens are removed x
pass
match 1:
case (
_
) if True: # comment over the line limit and parens should go to next line
pass