From e58dc0a3d940de0976ea0342f50e01aba8ac1d6f Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 30 Jul 2014 15:40:10 +0200 Subject: [PATCH] simplify evaluator.execute, because now everything is using py__call__ --- jedi/evaluate/__init__.py | 31 +++++++++---------------------- jedi/evaluate/iterable.py | 2 +- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/jedi/evaluate/__init__.py b/jedi/evaluate/__init__.py index c0c0ba25..f8344ece 100644 --- a/jedi/evaluate/__init__.py +++ b/jedi/evaluate/__init__.py @@ -312,7 +312,7 @@ class Evaluator(object): return self.follow_path(path, result, scope) @debug.increase_indent - def execute(self, obj, params=(), evaluate_generator=False): + def execute(self, obj, params=()): if obj.isinstance(er.Function): obj = obj.get_decorated_func() @@ -324,28 +324,15 @@ class Evaluator(object): except stdlib.NotInStdLib: pass - if isinstance(obj, iterable.GeneratorMethod): - return obj.py__call__(self, params) - elif obj.isinstance(compiled.CompiledObject): - return obj.py__call__(self, params) - elif obj.isinstance(er.Class): - # There maybe executions of executions. - return obj.py__call__(self, params) + try: + func = obj.py__call__ + except AttributeError: + debug.warning("no execution possible %s", obj) + return [] else: - stmts = [] - if obj.isinstance(er.Function): - return obj.py__call__(self, params, evaluate_generator) - else: - try: - func = obj.py__call__ - except AttributeError: - debug.warning("no execution possible %s", obj) - return [] - else: - return func(self, params) - - debug.dbg('execute result: %s in %s', stmts, obj) - return imports.follow_imports(self, stmts) + types = func(self, params) + debug.dbg('execute result: %s in %s', types, obj) + return types def goto(self, stmt, call_path): scope = stmt.get_parent_until(pr.IsScope) diff --git a/jedi/evaluate/iterable.py b/jedi/evaluate/iterable.py index 35800d7b..7491b589 100644 --- a/jedi/evaluate/iterable.py +++ b/jedi/evaluate/iterable.py @@ -62,7 +62,7 @@ class Generator(use_metaclass(CachedMetaClass, pr.Base)): def iter_content(self): """ returns the content of __iter__ """ - return self._evaluator.execute(self.func, self.var_args, True) + return self.func.py__call__(self._evaluator, self.var_args, True) def get_index_types(self, index_array): #debug.warning('Tried to get array access on a generator: %s', self)