Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grammar: accept open sequences on match subject #2639

Merged
merged 2 commits into from Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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, like `match a, b:` (#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