forked from VimPlug/jedi
Understanding implicit tuple returns (testlist)
This commit is contained in:
@@ -180,6 +180,7 @@ class Evaluator(object):
|
||||
return types
|
||||
|
||||
def eval_element(self, element):
|
||||
debug.dbg('eval_element %s', element)
|
||||
if isinstance(element, (pr.Name, pr.Literal)) or pr.is_node(element, 'atom'):
|
||||
return self._eval_atom(element)
|
||||
elif element.type == python_symbols.power:
|
||||
@@ -190,7 +191,7 @@ class Evaluator(object):
|
||||
types = self._eval_trailer(types, trailer)
|
||||
|
||||
return types
|
||||
elif pr.is_node(element, 'testlist_star_expr'):
|
||||
elif pr.is_node(element, 'testlist_star_expr', 'testlist'):
|
||||
# The implicit tuple in statements.
|
||||
return [iterable.Array(self, element, pr.Array.TUPLE)]
|
||||
else:
|
||||
|
||||
@@ -137,13 +137,13 @@ class Array(use_metaclass(CachedMetaClass, IterableWrapper)):
|
||||
return None # We don't know the length, because of appends.
|
||||
|
||||
@memoize_default(NO_DEFAULT)
|
||||
def get_index_types(self, index=()):
|
||||
def get_index_types(self, evaluator, index=()):
|
||||
"""
|
||||
Get the types of a specific index or all, if not given.
|
||||
|
||||
:param index: A subscriptlist node (or subnode).
|
||||
"""
|
||||
indexes = create_indexes_or_slices(self._evaluator, index)
|
||||
indexes = create_indexes_or_slices(evaluator, index)
|
||||
lookup_done = False
|
||||
types = []
|
||||
for index in indexes:
|
||||
@@ -213,7 +213,7 @@ class Array(use_metaclass(CachedMetaClass, IterableWrapper)):
|
||||
return self._items()
|
||||
|
||||
def _items(self):
|
||||
if pr.is_node(self._array_node, 'testlist_comp') or pr.is_node(self._array_node, 'testlist_star_expr'):
|
||||
if pr.is_node(self._array_node, 'testlist_comp', 'testlist_star_expr', 'testlist'):
|
||||
return self._array_node.children[::2]
|
||||
elif pr.is_node(self._array_node, 'dictorsetmaker'):
|
||||
kv = []
|
||||
|
||||
Reference in New Issue
Block a user