Skip to content
Commit 6b81441e authored by Francis Herne's avatar Francis Herne Committed by Sven Brauch
Browse files

Adds support for PEP-3132 'Extended Iterable Unpacking'

Support assignments of the form a, *b, c = 1, 2, 3, 4, 5,
after which b is [2, 3, 4].
BUG: 362521
Differential revision: https://phabricator.kde.org/D1751

Fix assignments of the form a = b = 7, a = b = 3, 4.

Fix assignment from a single-element tuple:
 foo = (3,) makes foo a tuple, not int.
Fix unpacking into a single-element tuple:
 foo, = [7] makes foo an int, not a list.

Fix unpacking of nested tuples: foo, (bar, baz) = 2, ('a', 5.5).
BUG: 359914

Declaration aliasing works for simple "a = b" assignment, e.g.

def aaa(a: int):
    return "a"
bbb = aaa

It _doesn't_ work for anything more advanced, e.g.

def aaa(a: int):
    return "a"
bbb, ccc = aaa, 4

although the function type is preserved.

This is a regression, aliasing works for non-nested tuple assignment
without this patch. The use case is however questionable and the benefit
of these changes is certainly more valuable.
parent 583101e1
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment