1
0
forked from VimPlug/jedi

Fix decorator issues with nested decorators and class combinations. Fixes #642.

This commit is contained in:
Dave Halter
2016-07-17 23:54:47 +02:00
parent 4b0e164d91
commit 20529d3405
2 changed files with 11 additions and 1 deletions

View File

@@ -553,8 +553,10 @@ class Function(use_metaclass(CachedMetaClass, Wrapper)):
# Create param array. # Create param array.
if isinstance(f, Function): if isinstance(f, Function):
old_func = f # TODO this is just hacky. change. old_func = f # TODO this is just hacky. change.
else: elif f.type == 'funcdef':
old_func = Function(self._evaluator, f, is_decorated=True) old_func = Function(self._evaluator, f, is_decorated=True)
else:
old_func = f
wrappers = self._evaluator.execute_evaluated(decorator, old_func) wrappers = self._evaluator.execute_evaluated(decorator, old_func)
if not len(wrappers): if not len(wrappers):

View File

@@ -78,6 +78,9 @@ exe[4]['d']
# ----------------- # -----------------
# Decorator is a class # Decorator is a class
# ----------------- # -----------------
def same_func(func):
return func
class Decorator(object): class Decorator(object):
def __init__(self, func): def __init__(self, func):
self.func = func self.func = func
@@ -94,10 +97,15 @@ nothing("")[0]
#? str() #? str()
nothing("")[1] nothing("")[1]
@same_func
@Decorator @Decorator
def nothing(a,b,c): def nothing(a,b,c):
return a,b,c return a,b,c
#? int()
nothing("")[0]
class MethodDecoratorAsClass(): class MethodDecoratorAsClass():
class_var = 3 class_var = 3
@Decorator @Decorator