import_stmt | global_stmt | nonlocal_stmt | assert_stmt)
expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
[('=' (yield_expr|testlist_star_expr))+ [TYPE_COMMENT]] )
-annassign: ':' test ['=' (yield_expr|testlist)]
+annassign: ':' test ['=' (yield_expr|testlist_star_expr)]
testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
'<<=' | '>>=' | '**=' | '//=')
exec(stmt, ns)
self.assertEqual(list(ns['f']()), [None])
+ ns = {"a": 1, 'b': (2, 3, 4), "c":5, "Tuple": typing.Tuple}
+ exec('x: Tuple[int, ...] = a,*b,c', ns)
+ self.assertEqual(ns['x'], (1, 2, 3, 4, 5))
+
def test_funcdef(self):
### [decorators] 'def' NAME parameters ['->' test] ':' suite
### decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
--- /dev/null
+Allow unpacking in the right hand side of annotated assignments. In
+particular, ``t: Tuple[int, ...] = x, y, *z`` is now allowed.
}
else {
ch = CHILD(ann, 3);
- if (TYPE(ch) == testlist) {
+ if (TYPE(ch) == testlist_star_expr) {
expr3 = ast_for_testlist(c, ch);
}
else {
{0, 2},
};
static const arc arcs_17_3[2] = {
- {47, 4},
+ {81, 4},
{84, 4},
};
static const arc arcs_17_4[1] = {