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:
parent
40759445c9
commit
dfa45cec9e
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user