grammar: accept open sequences on match subject (GH-2639)

* grammar: accept open sequences on match subject
* give an example about the fixed match subject
This commit is contained in:
Batuhan Taskaya 2021-11-25 04:21:36 +03:00 committed by GitHub
parent 40759445c9
commit dfa45cec9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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