forked from VimPlug/jedi
Fix issues with decorators and dynamic params combined.
This commit is contained in:
@@ -90,9 +90,10 @@ def search_params(evaluator, param):
|
|||||||
|
|
||||||
# TODO why not a direct comparison? functions seem to be
|
# TODO why not a direct comparison? functions seem to be
|
||||||
# decorated in types and not in compare...
|
# decorated in types and not in compare...
|
||||||
|
undecorated = [escope.decorates or escope for escope in types
|
||||||
|
if escope.isinstance(er.Function, er.Class)]
|
||||||
c = [getattr(escope, 'base_func', None) or escope.base
|
c = [getattr(escope, 'base_func', None) or escope.base
|
||||||
for escope in types
|
for escope in undecorated]
|
||||||
if escope.isinstance(er.Function, er.Class)]
|
|
||||||
if compare in c:
|
if compare in c:
|
||||||
# Only if we have the correct function we execute
|
# Only if we have the correct function we execute
|
||||||
# it, otherwise just ignore it.
|
# it, otherwise just ignore it.
|
||||||
|
|||||||
@@ -356,6 +356,7 @@ class Class(use_metaclass(CachedMetaClass, Wrapper)):
|
|||||||
def __init__(self, evaluator, base):
|
def __init__(self, evaluator, base):
|
||||||
self._evaluator = evaluator
|
self._evaluator = evaluator
|
||||||
self.base = base
|
self.base = base
|
||||||
|
self.decorates = None
|
||||||
|
|
||||||
@memoize_default(default=())
|
@memoize_default(default=())
|
||||||
def py__mro__(self, evaluator):
|
def py__mro__(self, evaluator):
|
||||||
@@ -454,6 +455,8 @@ class Function(use_metaclass(CachedMetaClass, Wrapper)):
|
|||||||
self._evaluator = evaluator
|
self._evaluator = evaluator
|
||||||
self.base = self.base_func = func
|
self.base = self.base_func = func
|
||||||
self.is_decorated = is_decorated
|
self.is_decorated = is_decorated
|
||||||
|
# A property that is set by the decorator resolution.
|
||||||
|
self.decorates = None
|
||||||
|
|
||||||
@memoize_default()
|
@memoize_default()
|
||||||
def _decorated_func(self):
|
def _decorated_func(self):
|
||||||
@@ -495,6 +498,8 @@ class Function(use_metaclass(CachedMetaClass, Wrapper)):
|
|||||||
debug.warning('multiple wrappers found %s %s',
|
debug.warning('multiple wrappers found %s %s',
|
||||||
self.base_func, wrappers)
|
self.base_func, wrappers)
|
||||||
f = wrappers[0]
|
f = wrappers[0]
|
||||||
|
if isinstance(f, (Class, Function)):
|
||||||
|
f.decorates = self
|
||||||
|
|
||||||
debug.dbg('decorator end %s', f)
|
debug.dbg('decorator end %s', f)
|
||||||
|
|
||||||
@@ -505,13 +510,10 @@ class Function(use_metaclass(CachedMetaClass, Wrapper)):
|
|||||||
def get_decorated_func(self):
|
def get_decorated_func(self):
|
||||||
"""
|
"""
|
||||||
This function exists for the sole purpose of returning itself if the
|
This function exists for the sole purpose of returning itself if the
|
||||||
decorator doesn't turn out to "work".
|
decorator doesn't turn out to "work", that means we cannot resolve it.
|
||||||
|
In that case ignore the decorator.
|
||||||
We just ignore the decorator here, because sometimes decorators are
|
|
||||||
just really complicated and Jedi cannot understand them.
|
|
||||||
"""
|
"""
|
||||||
return self._decorated_func() \
|
return self._decorated_func() or self
|
||||||
or Function(self._evaluator, self.base_func, True)
|
|
||||||
|
|
||||||
def get_magic_function_names(self):
|
def get_magic_function_names(self):
|
||||||
return compiled.magic_function_class.get_defined_names()
|
return compiled.magic_function_class.get_defined_names()
|
||||||
|
|||||||
Reference in New Issue
Block a user