Support as-expressions on dict items (GH-2686)
This commit is contained in:
parent
e7ddf524b0
commit
1c6b3a3a6f
@ -5,6 +5,8 @@
|
||||
### _Black_
|
||||
|
||||
- Improve error message for invalid regular expression (#2678)
|
||||
- Fix mapping cases that contain as-expressions, like `case {"key": 1 | 2 as password}`
|
||||
(#2686)
|
||||
|
||||
## 21.12b0
|
||||
|
||||
|
@ -168,8 +168,8 @@ subscript: test [':=' test] | [test] ':' [test] [sliceop]
|
||||
sliceop: ':' [test]
|
||||
exprlist: (expr|star_expr) (',' (expr|star_expr))* [',']
|
||||
testlist: test (',' test)* [',']
|
||||
dictsetmaker: ( ((test ':' test | '**' expr)
|
||||
(comp_for | (',' (test ':' test | '**' expr))* [','])) |
|
||||
dictsetmaker: ( ((test ':' asexpr_test | '**' expr)
|
||||
(comp_for | (',' (test ':' asexpr_test | '**' expr))* [','])) |
|
||||
((test [':=' test] | star_expr)
|
||||
(comp_for | (',' (test [':=' test] | star_expr))* [','])) )
|
||||
|
||||
|
@ -82,3 +82,13 @@ def func(match: case, case: match) -> case:
|
||||
match a, *b(), c:
|
||||
case d, *f, g:
|
||||
pass
|
||||
|
||||
|
||||
match something:
|
||||
case {
|
||||
"key": key as key_1,
|
||||
"password": PASS.ONE | PASS.TWO | PASS.THREE as password,
|
||||
}:
|
||||
pass
|
||||
case {"maybe": something(complicated as this) as that}:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user