mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
cleaned up DecoratorNotFound mess
This commit is contained in:
15
evaluate.py
15
evaluate.py
@@ -373,24 +373,16 @@ class Function(object):
|
|||||||
debug.dbg('decorator end', f)
|
debug.dbg('decorator end', f)
|
||||||
if f != self.base_func and isinstance(f, parsing.Function):
|
if f != self.base_func and isinstance(f, parsing.Function):
|
||||||
f = Function(f)
|
f = Function(f)
|
||||||
if f == None:
|
|
||||||
raise DecoratorNotFound('Accessed returns in function')
|
|
||||||
return f
|
return f
|
||||||
|
|
||||||
def get_decorated_func(self):
|
def get_decorated_func(self):
|
||||||
if self._decorated_func == None:
|
if self._decorated_func == None:
|
||||||
raise DecoratorNotFound('Accessed returns in function')
|
raise DecoratorNotFound()
|
||||||
if self._decorated_func == self.base_func:
|
if self._decorated_func == self.base_func:
|
||||||
return self
|
return self
|
||||||
return self._decorated_func
|
return self._decorated_func
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if name in ['get_defined_names', 'returns', 'params', 'statements',
|
|
||||||
'subscopes', 'imports', 'name', 'is_generator',
|
|
||||||
'get_parent_until']:
|
|
||||||
return getattr(self._decorated_func, name)
|
|
||||||
if name not in ['start_pos', 'end_pos', 'parent']:
|
|
||||||
raise AttributeError('Accessed name "%s" in function.' % name)
|
|
||||||
return getattr(self.base_func, name)
|
return getattr(self.base_func, name)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@@ -936,12 +928,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
break_scopes = []
|
break_scopes = []
|
||||||
# here is the position stuff happening (sorting of variables)
|
# here is the position stuff happening (sorting of variables)
|
||||||
for name in sorted(name_list, key=comparison_func, reverse=True):
|
for name in sorted(name_list, key=comparison_func, reverse=True):
|
||||||
try:
|
|
||||||
p = name.parent.parent if name.parent else None
|
p = name.parent.parent if name.parent else None
|
||||||
except DecoratorNotFound:
|
|
||||||
debug.warning('catched DecoratorNotFound: %s in %s' \
|
|
||||||
% (name, scope))
|
|
||||||
continue
|
|
||||||
if name_str == name.get_code() and p not in break_scopes:
|
if name_str == name.get_code() and p not in break_scopes:
|
||||||
result += handle_non_arrays(name)
|
result += handle_non_arrays(name)
|
||||||
# for comparison we need the raw class
|
# for comparison we need the raw class
|
||||||
|
|||||||
Reference in New Issue
Block a user