When an iterable of tuples is used in a 'for' statement, and there are multiple variables in the 'target list' (thus unpacking the tuple), their types are incorrect.
Unpacking a tuple in a normal assignment gives the correct types to the target variables:
t = ("x", 0.5)
a,b = t
# 't' is tuple, 'a' is string, 'b' is float.
But when iterating over a list of tuples, and unpacking directly in the 'for' statement, KDevelop seems not to handle the unpacking at all:
seq = [("x", 0.5)]
for a,b in seq:
The type of 'a' shows as 'mixed' (unknown), and 'b' is typed as tuple<string,float>. Instead, 'a' should be 'string' and 'b' should be 'float'.
Git commit f24284763f9b82366d8f86ee1f0f179333747d62 by Sven Brauch.
Committed on 26/08/2012 at 21:46.
Pushed by brauch into branch 'master'.
Support iterating over lists of tuples while unpacking those.
c = [(1, 2)]
for a, b in c: print a, b # a, b are ints
M +48 -7 duchain/declarationbuilder.cpp
M +24 -0 duchain/expressionvisitor.cpp
M +4 -0 duchain/tests/pyduchaintest.cpp