forked from psf/black
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A follow up to psf#4024 but for `if` guards in `case` statements. I noticed this when psf#4024 was made stable, and noticed I had some code that had extra parens around the `if` guard.
- Loading branch information
Showing
6 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
tests/data/cases/remove_redundant_parens_in_case_guard.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# 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 |