1
0
forked from VimPlug/jedi

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
+7 -7
View File
@@ -447,7 +447,7 @@ def unpack_tuple_to_dict(evaluator, types, exprlist):
'testlist_star_expr'): 'testlist_star_expr'):
dct = {} dct = {}
parts = iter(exprlist.children[::2]) parts = iter(exprlist.children[::2])
for iter_types in py__iter__(evaluator, types): for iter_types in py__iter__(evaluator, types, exprlist):
try: try:
part = next(parts) part = next(parts)
except StopIteration: except StopIteration:
@@ -656,14 +656,14 @@ class _ArrayInstance(IterableWrapper):
types = set() types = set()
else: else:
types = unite(self._evaluator.eval_element(node) for node in first_nodes) types = unite(self._evaluator.eval_element(node) for node in first_nodes)
for types in py__iter__(self._evaluator, types, first_nodes[0]): for types in py__iter__(self._evaluator, types, first_nodes[0]):
yield types yield types
module = self.var_args.get_parent_until()
is_list = str(self.instance.name) == 'list' module = self.var_args.get_parent_until()
additions = _check_array_additions(self._evaluator, self.instance, module, is_list) is_list = str(self.instance.name) == 'list'
if additions: additions = _check_array_additions(self._evaluator, self.instance, module, is_list)
yield additions if additions:
yield additions
class Slice(object): class Slice(object):
+4 -3
View File
@@ -154,12 +154,13 @@ def builtins_super(evaluator, types, objects, scope):
return set() return set()
@argument_clinic('sequence, /', want_obj=True) @argument_clinic('sequence, /', want_obj=True, want_arguments=True)
def builtins_reversed(evaluator, sequences, obj): def builtins_reversed(evaluator, sequences, obj, arguments):
# While we could do without this variable (just by using sequences), we # While we could do without this variable (just by using sequences), we
# want static analysis to work well. Therefore we need to generated the # want static analysis to work well. Therefore we need to generated the
# values again. # 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)] rev = [iterable.AlreadyEvaluated(o) for o in reversed(ordered)]
# Repack iterator values and then run it the normal way. This is # Repack iterator values and then run it the normal way. This is
+1 -1
View File
@@ -121,7 +121,7 @@ def _paths_from_assignment(evaluator, expr_stmt):
from jedi.evaluate.iterable import py__iter__ from jedi.evaluate.iterable import py__iter__
from jedi.evaluate.precedence import is_string from jedi.evaluate.precedence import is_string
types = evaluator.eval_element(expr_stmt) 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: for typ in types:
if is_string(typ): if is_string(typ):
yield typ.obj yield typ.obj