From 20529d34050e1bf400c0ef376e97cefc00ec5f12 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 17 Jul 2016 23:54:47 +0200 Subject: [PATCH] Fix decorator issues with nested decorators and class combinations. Fixes #642. --- jedi/evaluate/representation.py | 4 +++- test/completion/decorators.py | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index 700a91cd..bd578967 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -553,8 +553,10 @@ class Function(use_metaclass(CachedMetaClass, Wrapper)): # Create param array. if isinstance(f, Function): old_func = f # TODO this is just hacky. change. - else: + elif f.type == 'funcdef': old_func = Function(self._evaluator, f, is_decorated=True) + else: + old_func = f wrappers = self._evaluator.execute_evaluated(decorator, old_func) if not len(wrappers): diff --git a/test/completion/decorators.py b/test/completion/decorators.py index 7c4da05f..97460a4a 100644 --- a/test/completion/decorators.py +++ b/test/completion/decorators.py @@ -78,6 +78,9 @@ exe[4]['d'] # ----------------- # Decorator is a class # ----------------- +def same_func(func): + return func + class Decorator(object): def __init__(self, func): self.func = func @@ -94,10 +97,15 @@ nothing("")[0] #? str() nothing("")[1] + +@same_func @Decorator def nothing(a,b,c): return a,b,c +#? int() +nothing("")[0] + class MethodDecoratorAsClass(): class_var = 3 @Decorator