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 60e1838
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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 60e1838

Please sign in to comment.