Skip to content

Commit

Permalink
grammar: accept open sequences on match subject
Browse files Browse the repository at this point in the history
  • Loading branch information
isidentical committed Nov 24, 2021
1 parent 4075944 commit 5ce4954
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -5,6 +5,7 @@
### _Black_

- Fixed Python 3.10 support on platforms without ProcessPoolExecutor (#2631)
- Fixed `match` statements with open sequence subjects (#2639)

## 21.11b1

Expand Down
2 changes: 1 addition & 1 deletion src/blib2to3/Grammar.txt
Expand Up @@ -238,7 +238,7 @@ yield_arg: 'from' test | testlist_star_expr
# to reformat them.

match_stmt: "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT
subject_expr: namedexpr_test
subject_expr: namedexpr_test (',' namedexpr_test)* [',']

# cases
case_block: "case" patterns [guard] ':' suite
Expand Down
16 changes: 16 additions & 0 deletions tests/data/pattern_matching_extras.py
Expand Up @@ -27,3 +27,19 @@ def func(match: case, case: match) -> case:
...
case func(match, case):
...


match maybe, multiple:
case perhaps, 5:
pass
case perhaps, 6,:
pass


match more := (than, one), indeed,:
case _, (5, 6):
pass
case [[5], (6)], [7],:
pass
case _:
pass

0 comments on commit 5ce4954

Please sign in to comment.