mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-35814: Allow same r.h.s. in annotated assignments as in normal ones (GH-11667)
This commit is contained in:
parent
1396d8fab4
commit
62c35a8a8f
6 changed files with 23 additions and 6 deletions
|
@ -445,6 +445,15 @@ class GrammarTests(unittest.TestCase):
|
|||
exec('X: str', {}, CNS2())
|
||||
self.assertEqual(nonloc_ns['__annotations__']['x'], str)
|
||||
|
||||
def test_var_annot_rhs(self):
|
||||
ns = {}
|
||||
exec('x: tuple = 1, 2', ns)
|
||||
self.assertEqual(ns['x'], (1, 2))
|
||||
stmt = ('def f():\n'
|
||||
' x: int = yield')
|
||||
exec(stmt, ns)
|
||||
self.assertEqual(list(ns['f']()), [None])
|
||||
|
||||
def test_funcdef(self):
|
||||
### [decorators] 'def' NAME parameters ['->' test] ':' suite
|
||||
### decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue