forked from VimPlug/jedi
Fix issues with py__iter__types.
This commit is contained in:
@@ -301,7 +301,7 @@ def _name_to_types(evaluator, name, scope):
|
|||||||
typ = name.get_definition()
|
typ = name.get_definition()
|
||||||
if typ.isinstance(tree.ForStmt, tree.CompFor):
|
if typ.isinstance(tree.ForStmt, tree.CompFor):
|
||||||
container_types = evaluator.eval_element(typ.children[3])
|
container_types = evaluator.eval_element(typ.children[3])
|
||||||
for_types = common.unite(iterable.py__iter__(evaluator, container_types))
|
for_types = iterable.py__iter__types(evaluator, container_types)
|
||||||
types = check_tuple_assignments(for_types, name)
|
types = check_tuple_assignments(for_types, name)
|
||||||
elif isinstance(typ, tree.Param):
|
elif isinstance(typ, tree.Param):
|
||||||
types = _eval_param(evaluator, typ, scope)
|
types = _eval_param(evaluator, typ, scope)
|
||||||
|
|||||||
@@ -500,6 +500,14 @@ def py__iter__(evaluator, types):
|
|||||||
yield result
|
yield result
|
||||||
|
|
||||||
|
|
||||||
|
def py__iter__types(evaluator, types):
|
||||||
|
"""
|
||||||
|
Calls `py__iter__`, but ignores the ordering in the end and just returns
|
||||||
|
all types that it contains.
|
||||||
|
"""
|
||||||
|
return unite(py__iter__(evaluator, types))
|
||||||
|
|
||||||
|
|
||||||
def get_iterator_types(evaluator, element):
|
def get_iterator_types(evaluator, element):
|
||||||
"""Returns the types of any iterator (arrays, yields, __iter__, etc)."""
|
"""Returns the types of any iterator (arrays, yields, __iter__, etc)."""
|
||||||
iterators = []
|
iterators = []
|
||||||
@@ -580,7 +588,8 @@ def _check_array_additions(evaluator, compare_array, module, is_list):
|
|||||||
result |= unite(evaluator.eval_element(node) for node in nodes)
|
result |= unite(evaluator.eval_element(node) for node in nodes)
|
||||||
elif add_name in ['extend', 'update']:
|
elif add_name in ['extend', 'update']:
|
||||||
for key, nodes in params:
|
for key, nodes in params:
|
||||||
result |= unite(get_iterator_types(evaluator, node) for node in nodes)
|
types = unite(evaluator.eval_element(n) for n in nodes)
|
||||||
|
result |= py__iter__types(evaluator, types)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
from jedi.evaluate import representation as er, param
|
from jedi.evaluate import representation as er, param
|
||||||
@@ -691,8 +700,8 @@ class _ArrayInstance(IterableWrapper):
|
|||||||
"""
|
"""
|
||||||
items = set()
|
items = set()
|
||||||
for key, nodes in self.var_args.unpack():
|
for key, nodes in self.var_args.unpack():
|
||||||
for node in nodes:
|
types = unite(self._evaluator.eval_element(n) for n in nodes)
|
||||||
items |= get_iterator_types(self._evaluator, node)
|
items |= py__iter__types(self._evaluator, types)
|
||||||
|
|
||||||
module = self.var_args.get_parent_until()
|
module = self.var_args.get_parent_until()
|
||||||
is_list = str(self.instance.name) == 'list'
|
is_list = str(self.instance.name) == 'list'
|
||||||
|
|||||||
@@ -153,7 +153,8 @@ def builtins_super(evaluator, types, objects, scope):
|
|||||||
|
|
||||||
def get_iterable_content(evaluator, arguments, argument_index):
|
def get_iterable_content(evaluator, arguments, argument_index):
|
||||||
nodes = list(arguments.unpack())[argument_index][1]
|
nodes = list(arguments.unpack())[argument_index][1]
|
||||||
return unite(iterable.get_iterator_types(evaluator, node) for node in nodes)
|
types = unite(evaluator.eval_element(n) for n in nodes)
|
||||||
|
return iterable.py__iter__types(evaluator, types)
|
||||||
|
|
||||||
|
|
||||||
@argument_clinic('sequence, /', want_obj=True, want_arguments=True)
|
@argument_clinic('sequence, /', want_obj=True, want_arguments=True)
|
||||||
|
|||||||
@@ -118,11 +118,13 @@ def _paths_from_assignment(evaluator, expr_stmt):
|
|||||||
except AssertionError:
|
except AssertionError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
from jedi.evaluate.iterable import get_iterator_types
|
from jedi.evaluate.iterable import py__iter__
|
||||||
from jedi.evaluate.precedence import is_string
|
from jedi.evaluate.precedence import is_string
|
||||||
for val in get_iterator_types(evaluator, expr_stmt):
|
types = evaluator.eval_element(expr_stmt)
|
||||||
if is_string(val):
|
for types in py__iter__(evaluator, types):
|
||||||
yield val.obj
|
for typ in types:
|
||||||
|
if is_string(typ):
|
||||||
|
yield typ.obj
|
||||||
|
|
||||||
|
|
||||||
def _paths_from_list_modifications(module_path, trailer1, trailer2):
|
def _paths_from_list_modifications(module_path, trailer1, trailer2):
|
||||||
|
|||||||
Reference in New Issue
Block a user