1
0
forked from VimPlug/jedi

fix a few more tracebacks

This commit is contained in:
Dave Halter
2014-01-09 17:54:40 +01:00
parent dfd9a779c3
commit 0234c1429b
2 changed files with 16 additions and 16 deletions

View File

@@ -331,8 +331,8 @@ class Evaluator(object):
results_new = [] results_new = []
iter_paths = itertools.tee(path, len(types)) iter_paths = itertools.tee(path, len(types))
for i, type in enumerate(types): for i, typ in enumerate(types):
fp = self._follow_path(iter_paths[i], type, call_scope, position=position) fp = self._follow_path(iter_paths[i], typ, call_scope, position=position)
if fp is not None: if fp is not None:
results_new += fp results_new += fp
else: else:
@@ -340,7 +340,7 @@ class Evaluator(object):
return types return types
return results_new return results_new
def _follow_path(self, path, type, scope, position=None): def _follow_path(self, path, typ, scope, position=None):
""" """
Uses a generator and tries to complete the path, e.g.:: Uses a generator and tries to complete the path, e.g.::
@@ -354,31 +354,31 @@ class Evaluator(object):
current = next(path) current = next(path)
except StopIteration: except StopIteration:
return None return None
debug.dbg('_follow_path: %s in scope %s' % (current, type)) debug.dbg('_follow_path: %s in scope %s' % (current, typ))
result = [] result = []
if isinstance(current, pr.Array): if isinstance(current, pr.Array):
# This must be an execution, either () or []. # This must be an execution, either () or [].
if current.type == pr.Array.LIST: if current.type == pr.Array.LIST:
if hasattr(type, 'get_index_types'): if hasattr(typ, 'get_index_types'):
result = type.get_index_types(current) result = typ.get_index_types(current)
elif current.type not in [pr.Array.DICT]: elif current.type not in [pr.Array.DICT]:
# Scope must be a class or func - make an instance or execution. # Scope must be a class or func - make an instance or execution.
debug.dbg('exe', type) debug.dbg('exe', typ)
result = self.execute(type, current) result = self.execute(typ, current)
else: else:
# Curly braces are not allowed, because they make no sense. # Curly braces are not allowed, because they make no sense.
debug.warning('strange function call with {}', current, type) debug.warning('strange function call with {}', current, typ)
else: else:
# The function must not be decorated with something else. # The function must not be decorated with something else.
if type.isinstance(er.Function): if typ.isinstance(er.Function):
type = type.get_magic_function_scope() typ = typ.get_magic_function_scope()
else: else:
# This is the typical lookup while chaining things. # This is the typical lookup while chaining things.
if filter_private_variable(type, scope, current): if filter_private_variable(typ, scope, current):
return [] return []
result = imports.strip_imports(self, self.find_types(type, current, types = self.find_types(typ, current, position=position)
position=position)) result = imports.strip_imports(self, types)
return self.follow_path(path, set(result), scope, position=position) return self.follow_path(path, set(result), scope, position=position)
def execute(self, obj, params=(), evaluate_generator=False): def execute(self, obj, params=(), evaluate_generator=False):
@@ -391,7 +391,7 @@ class Evaluator(object):
pass pass
if isinstance(obj, compiled.PyObject): if isinstance(obj, compiled.PyObject):
return obj.execute(params) return list(obj.execute(params))
elif obj.isinstance(er.Class): elif obj.isinstance(er.Class):
# There maybe executions of executions. # There maybe executions of executions.
return [er.Instance(self, obj, params)] return [er.Instance(self, obj, params)]

View File

@@ -379,7 +379,7 @@ class Function(use_metaclass(CachedMetaClass, pr.IsScope)):
return compiled.magic_function_class.get_defined_names() return compiled.magic_function_class.get_defined_names()
def get_magic_function_scope(self): def get_magic_function_scope(self):
return compiled.magic_function_class.get_defined_names() return compiled.magic_function_class
def __getattr__(self, name): def __getattr__(self, name):
return getattr(self.base_func, name) return getattr(self.base_func, name)