mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-01 17:53:21 +08:00
Start implementing py__iter__ for all classes.
This commit is contained in:
@@ -301,7 +301,8 @@ def _name_to_types(evaluator, name, scope):
|
||||
types = set()
|
||||
typ = name.get_definition()
|
||||
if typ.isinstance(tree.ForStmt, tree.CompFor):
|
||||
for_types = iterable.get_iterator_types(evaluator, typ.children[3])
|
||||
container_types = evaluator.eval_element(typ.children[3])
|
||||
for_types = common.unite(iterable.py__iter__(evaluator, container_types))
|
||||
types |= check_tuple_assignments(for_types, name)
|
||||
elif isinstance(typ, tree.Param):
|
||||
types |= _eval_param(evaluator, typ, scope)
|
||||
|
||||
@@ -474,6 +474,16 @@ def unpack_tuple_to_dict(evaluator, types, exprlist):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def py__iter__(evaluator, types):
|
||||
for typ in types:
|
||||
for result in typ.py__iter__():
|
||||
yield result
|
||||
|
||||
|
||||
def py__iter__types(evaluator, types):
|
||||
return unite(py__iter__(evaluator, types))
|
||||
|
||||
|
||||
def get_iterator_types(evaluator, element):
|
||||
"""Returns the types of any iterator (arrays, yields, __iter__, etc)."""
|
||||
iterators = []
|
||||
|
||||
Reference in New Issue
Block a user