Final fixes for pure usage of py__iter__.

This commit is contained in:
Dave Halter
2015-12-04 00:15:48 +01:00
parent 5f36019752
commit 76345c0b58
3 changed files with 12 additions and 11 deletions

View File

@@ -447,7 +447,7 @@ def unpack_tuple_to_dict(evaluator, types, exprlist):
'testlist_star_expr'):
dct = {}
parts = iter(exprlist.children[::2])
for iter_types in py__iter__(evaluator, types):
for iter_types in py__iter__(evaluator, types, exprlist):
try:
part = next(parts)
except StopIteration:
@@ -656,14 +656,14 @@ class _ArrayInstance(IterableWrapper):
types = set()
else:
types = unite(self._evaluator.eval_element(node) for node in first_nodes)
for types in py__iter__(self._evaluator, types, first_nodes[0]):
yield types
module = self.var_args.get_parent_until()
is_list = str(self.instance.name) == 'list'
additions = _check_array_additions(self._evaluator, self.instance, module, is_list)
if additions:
yield additions
module = self.var_args.get_parent_until()
is_list = str(self.instance.name) == 'list'
additions = _check_array_additions(self._evaluator, self.instance, module, is_list)
if additions:
yield additions
class Slice(object):

View File

@@ -154,12 +154,13 @@ def builtins_super(evaluator, types, objects, scope):
return set()
@argument_clinic('sequence, /', want_obj=True)
def builtins_reversed(evaluator, sequences, obj):
@argument_clinic('sequence, /', want_obj=True, want_arguments=True)
def builtins_reversed(evaluator, sequences, obj, arguments):
# While we could do without this variable (just by using sequences), we
# want static analysis to work well. Therefore we need to generated the
# values again.
ordered = list(iterable.py__iter__(evaluator, sequences))
first_arg = next(arguments.as_tuple())[0]
ordered = list(iterable.py__iter__(evaluator, sequences, first_arg))
rev = [iterable.AlreadyEvaluated(o) for o in reversed(ordered)]
# Repack iterator values and then run it the normal way. This is

View File

@@ -121,7 +121,7 @@ def _paths_from_assignment(evaluator, expr_stmt):
from jedi.evaluate.iterable import py__iter__
from jedi.evaluate.precedence import is_string
types = evaluator.eval_element(expr_stmt)
for types in py__iter__(evaluator, types):
for types in py__iter__(evaluator, types, expr_stmt):
for typ in types:
if is_string(typ):
yield typ.obj