mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
decorator's that are not found, are now just being ignored / introduced new testing file
This commit is contained in:
20
evaluate.py
20
evaluate.py
@@ -34,7 +34,17 @@ import builtin
|
||||
memoize_caches = []
|
||||
|
||||
|
||||
class DecoratorNotFound(LookupError):
|
||||
"""
|
||||
Decorators are sometimes not found, if that happens, that error is raised.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class MultiLevelStopIteration(Exception):
|
||||
"""
|
||||
StopIteration's get catched pretty easy by for loops, let errors propagate.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -56,6 +66,7 @@ class MultiLevelAttributeError(BaseException):
|
||||
return 'Original:\n\n' + ''.join(tb)
|
||||
|
||||
|
||||
|
||||
def clear_caches():
|
||||
for m in memoize_caches:
|
||||
m.clear()
|
||||
@@ -339,6 +350,8 @@ class Function(object):
|
||||
return f
|
||||
|
||||
def __getattr__(self, name):
|
||||
if self.decorated_func == None:
|
||||
raise DecoratorNotFound()
|
||||
return getattr(self.decorated_func, name)
|
||||
|
||||
def __repr__(self):
|
||||
@@ -379,7 +392,7 @@ class Execution(Executable):
|
||||
try:
|
||||
# if it is an instance, we try to execute the __call__().
|
||||
call_method = self.base.get_subscope_by_name('__call__')
|
||||
except (AttributeError, KeyError):
|
||||
except (AttributeError, KeyError, DecoratorNotFound):
|
||||
debug.warning("no execution possible", self.base)
|
||||
else:
|
||||
debug.dbg('__call__', call_method, self.base)
|
||||
@@ -886,7 +899,12 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
||||
break_scopes = []
|
||||
# here is the position stuff happening (sorting of variables)
|
||||
for name in sorted(name_list, key=comparison_func, reverse=True):
|
||||
try:
|
||||
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:
|
||||
result += handle_non_arrays(name)
|
||||
# for comparison we need the raw class
|
||||
|
||||
@@ -151,6 +151,31 @@ CallClass()()
|
||||
# properties
|
||||
# -----------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class B():
|
||||
@property
|
||||
def r(self):
|
||||
@@ -172,6 +197,8 @@ B().p
|
||||
##? []
|
||||
B().p()
|
||||
|
||||
property2 = property
|
||||
|
||||
# -----------------
|
||||
# class decorators
|
||||
# -----------------
|
||||
|
||||
27
test/completion/decorators.py
Normal file
27
test/completion/decorators.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# -----------------
|
||||
# not found decorators
|
||||
# -----------------
|
||||
@not_found_decorator
|
||||
def just_a_func():
|
||||
return 1
|
||||
|
||||
#? []
|
||||
just_a_func()
|
||||
|
||||
#? []
|
||||
just_a_func.
|
||||
|
||||
|
||||
class JustAClass:
|
||||
@not_found_decorator2
|
||||
def a(self):
|
||||
return 1
|
||||
|
||||
#? []
|
||||
JustAClass().a.
|
||||
#? []
|
||||
JustAClass().a()
|
||||
#? []
|
||||
JustAClass.a.
|
||||
#? []
|
||||
JustAClass().a()
|
||||
@@ -222,7 +222,6 @@ exe = fu(list, set, 3, '', d='')
|
||||
#? str()
|
||||
exe[3][0]
|
||||
|
||||
|
||||
# -----------------
|
||||
# generators
|
||||
# -----------------
|
||||
|
||||
Reference in New Issue
Block a user