Bug 362521 - PEP-3132 not supported
Summary: PEP-3132 not supported
Status: RESOLVED FIXED
Alias: None
Product: kdev-python
Classification: Developer tools
Component: Language support (show other bugs)
Version: 4.90.91
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: 1.7.3
Assignee: Sven Brauch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-30 21:04 UTC by Francis Herne
Modified: 2016-06-02 21:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francis Herne 2016-04-30 21:04:37 UTC
PEP-3132 "Extended Iterable Unpacking" (https://www.python.org/dev/peps/pep-3132/), part of Python 3.0, allows the syntax:

`a, *b, c = range(5)`
Resulting in a == 0; b == [1,2,3]; c == 4

kdev-python doesn't like this and warns that 'b' is undefined.
Comment 1 Sven Brauch 2016-06-02 21:22:34 UTC
Git commit 6b81441e0db9a7c34dccc627cf99c0785a00afed by Sven Brauch, on behalf of Francis Herne.
Committed on 02/06/2016 at 20:41.
Pushed by brauch into branch '5.0'.

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].
Related: bug 359914
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).

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.

M  +86   -104  duchain/declarationbuilder.cpp
M  +12   -15   duchain/declarationbuilder.h
M  +27   -2    duchain/tests/pyduchaintest.cpp

http://commits.kde.org/kdev-python/6b81441e0db9a7c34dccc627cf99c0785a00afed