mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
decorator's that are not found, are now just being ignored / introduced new testing file
This commit is contained in:
22
evaluate.py
22
evaluate.py
@@ -34,7 +34,17 @@ import builtin
|
|||||||
memoize_caches = []
|
memoize_caches = []
|
||||||
|
|
||||||
|
|
||||||
|
class DecoratorNotFound(LookupError):
|
||||||
|
"""
|
||||||
|
Decorators are sometimes not found, if that happens, that error is raised.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MultiLevelStopIteration(Exception):
|
class MultiLevelStopIteration(Exception):
|
||||||
|
"""
|
||||||
|
StopIteration's get catched pretty easy by for loops, let errors propagate.
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -56,6 +66,7 @@ class MultiLevelAttributeError(BaseException):
|
|||||||
return 'Original:\n\n' + ''.join(tb)
|
return 'Original:\n\n' + ''.join(tb)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def clear_caches():
|
def clear_caches():
|
||||||
for m in memoize_caches:
|
for m in memoize_caches:
|
||||||
m.clear()
|
m.clear()
|
||||||
@@ -339,6 +350,8 @@ class Function(object):
|
|||||||
return f
|
return f
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
|
if self.decorated_func == None:
|
||||||
|
raise DecoratorNotFound()
|
||||||
return getattr(self.decorated_func, name)
|
return getattr(self.decorated_func, name)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@@ -379,7 +392,7 @@ class Execution(Executable):
|
|||||||
try:
|
try:
|
||||||
# if it is an instance, we try to execute the __call__().
|
# if it is an instance, we try to execute the __call__().
|
||||||
call_method = self.base.get_subscope_by_name('__call__')
|
call_method = self.base.get_subscope_by_name('__call__')
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError, DecoratorNotFound):
|
||||||
debug.warning("no execution possible", self.base)
|
debug.warning("no execution possible", self.base)
|
||||||
else:
|
else:
|
||||||
debug.dbg('__call__', call_method, self.base)
|
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 = []
|
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):
|
||||||
p = name.parent.parent if name.parent else None
|
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:
|
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
|
||||||
|
|||||||
@@ -151,6 +151,31 @@ CallClass()()
|
|||||||
# properties
|
# properties
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class B():
|
class B():
|
||||||
@property
|
@property
|
||||||
def r(self):
|
def r(self):
|
||||||
@@ -172,6 +197,8 @@ B().p
|
|||||||
##? []
|
##? []
|
||||||
B().p()
|
B().p()
|
||||||
|
|
||||||
|
property2 = property
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# class decorators
|
# 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()
|
#? str()
|
||||||
exe[3][0]
|
exe[3][0]
|
||||||
|
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# generators
|
# generators
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user