forked from VimPlug/jedi
Attempt to improve tuple unpackings
This commit is contained in:
@@ -865,10 +865,16 @@ def check_tuple_assignments(name, value_set):
|
|||||||
# For no star unpacking is not possible.
|
# For no star unpacking is not possible.
|
||||||
return NO_VALUES
|
return NO_VALUES
|
||||||
i = 0
|
i = 0
|
||||||
|
lazy_value = None
|
||||||
while i <= index:
|
while i <= index:
|
||||||
try:
|
try:
|
||||||
lazy_value = next(iterated)
|
lazy_value = next(iterated)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
|
# A desperate attempt to fix inference for tuples from an
|
||||||
|
# iterator.
|
||||||
|
if lazy_value is not None:
|
||||||
|
return lazy_value.infer()
|
||||||
|
|
||||||
# We could do this with the default param in next. But this
|
# We could do this with the default param in next. But this
|
||||||
# would allow this loop to run for a very long time if the
|
# would allow this loop to run for a very long time if the
|
||||||
# index number is high. Therefore break if the loop is
|
# index number is high. Therefore break if the loop is
|
||||||
|
|||||||
@@ -155,8 +155,9 @@ class AbstractInstanceValue(Value):
|
|||||||
return super().py__iter__(contextualized_node)
|
return super().py__iter__(contextualized_node)
|
||||||
|
|
||||||
def iterate():
|
def iterate():
|
||||||
for generator in self.execute_function_slots(iter_slot_names):
|
yield LazyKnownValues(
|
||||||
yield from generator.py__next__(contextualized_node)
|
self.execute_function_slots(iter_slot_names).py__next__(contextualized_node).infer()
|
||||||
|
)
|
||||||
return iterate()
|
return iterate()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|||||||
@@ -207,16 +207,16 @@ C().a
|
|||||||
(f, g) = (1,)
|
(f, g) = (1,)
|
||||||
#? int()
|
#? int()
|
||||||
f
|
f
|
||||||
#? []
|
#? int()
|
||||||
g.
|
g
|
||||||
|
|
||||||
(f, g, h) = (1,'')
|
(f, g, h) = (1,'')
|
||||||
#? int()
|
#? int()
|
||||||
f
|
f
|
||||||
#? str()
|
#? str()
|
||||||
g
|
g
|
||||||
#? []
|
#? str()
|
||||||
h.
|
h
|
||||||
|
|
||||||
(f1, g1) = 1
|
(f1, g1) = 1
|
||||||
#? []
|
#? []
|
||||||
@@ -311,9 +311,13 @@ for x in {1: 3.0, '': 1j}:
|
|||||||
dict().values().__iter__
|
dict().values().__iter__
|
||||||
|
|
||||||
d = dict(a=3, b='')
|
d = dict(a=3, b='')
|
||||||
x, = d.values()
|
x, y, z = d.values()
|
||||||
#? int() str()
|
#? int() str()
|
||||||
x
|
x
|
||||||
|
#? int() str()
|
||||||
|
y
|
||||||
|
#? int() str()
|
||||||
|
z
|
||||||
#? int()
|
#? int()
|
||||||
d['a']
|
d['a']
|
||||||
#? int() str() None
|
#? int() str() None
|
||||||
|
|||||||
Reference in New Issue
Block a user