1
0
forked from VimPlug/jedi

Prepare replacing get_iterator_types.

This commit is contained in:
Dave Halter
2015-09-22 17:34:46 +02:00
parent 88bcb8e476
commit 786217acad
3 changed files with 9 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ CODES = {
'type-error-star-star': (9, TypeError, None),
'type-error-star': (10, TypeError, None),
'type-error-operation': (11, TypeError, None),
'type-error-not-iterable': (12, TypeError, None),
}

View File

@@ -389,6 +389,7 @@ def get_iterator_types(inputs):
iterators.append(it)
else:
if not hasattr(it, 'execute_subscope_by_name'):
analysis.add(self._evaluator, 'type-error-generator', index_array)
debug.warning('iterator/for loop input wrong: %s', it)
continue
try:

View File

@@ -54,7 +54,7 @@ def _follow_param(evaluator, arguments, index):
return iterable.unite(evaluator.eval_element(v) for v in values)
def argument_clinic(string, want_obj=False, want_scope=False):
def argument_clinic(string, want_obj=False, want_scope=False, want_arguments=False):
"""
Works like Argument Clinic (PEP 436), to validate function params.
"""
@@ -87,6 +87,8 @@ def argument_clinic(string, want_obj=False, want_scope=False):
kwargs['scope'] = arguments.scope()
if want_obj:
kwargs['obj'] = obj
if want_obj:
kwargs['arguments'] = arguments
return func(evaluator, *lst, **kwargs)
return wrapper
@@ -146,9 +148,11 @@ def builtins_super(evaluator, types, objects, scope):
return []
@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):
# Unpack the iterator values
# TODO replace get_iterator_types.
#elements = list(arguments.unpack())[0][1]
objects = tuple(iterable.get_iterator_types(sequences))
rev = [iterable.AlreadyEvaluated([o]) for o in reversed(objects)]
# Repack iterator values and then run it the normal way. This is