mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
bpo-40769: Allow extra surrounding parentheses for invalid annotated assignment rule (GH-20387)
This commit is contained in:
parent
6dcbc2422d
commit
c8f29ad986
3 changed files with 284 additions and 207 deletions
|
@ -646,8 +646,12 @@ invalid_named_expression:
|
|||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
|
||||
a, "cannot use assignment expressions with %s", _PyPegen_get_expr_name(a)) }
|
||||
invalid_assignment:
|
||||
| a=list ':' expression { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not list) can be annotated") }
|
||||
| a=tuple ':' expression { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not tuple) can be annotated") }
|
||||
| a=invalid_ann_assign_target ':' expression {
|
||||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
|
||||
a,
|
||||
"only single target (not %s) can be annotated",
|
||||
_PyPegen_get_expr_name(a)
|
||||
)}
|
||||
| a=star_named_expression ',' star_named_expressions* ':' expression {
|
||||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not tuple) can be annotated") }
|
||||
| a=expression ':' expression {
|
||||
|
@ -661,6 +665,10 @@ invalid_assignment:
|
|||
"'%s' is an illegal expression for augmented assignment",
|
||||
_PyPegen_get_expr_name(a)
|
||||
)}
|
||||
invalid_ann_assign_target[expr_ty]:
|
||||
| list
|
||||
| tuple
|
||||
| '(' a=invalid_ann_assign_target ')' { a }
|
||||
invalid_del_stmt:
|
||||
| 'del' a=star_expressions {
|
||||
RAISE_SYNTAX_ERROR_INVALID_TARGET(DEL_TARGETS, a) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue