Fix signatures if a decorator has no signatures, fixes #1705

This commit is contained in:
Dave Halter
2020-12-28 00:47:10 +01:00
parent 04c1c0f871
commit 5d2aed34f4
2 changed files with 10 additions and 0 deletions

View File

@@ -19,3 +19,11 @@ class Decoratee(ValueWrapper):
Decoratee(v, self._original_value)
for v in self._wrapped_value.py__get__(instance, class_value)
)
def get_signatures(self):
signatures = self._wrapped_value.get_signatures()
if signatures:
return signatures
# Fallback to signatures of the original function/class if the
# decorator has no signature or it is not inferrable.
return self._original_value.get_signatures()

View File

@@ -102,6 +102,8 @@ class X:
(partialmethod_code + 'X().d(', None),
(partialmethod_code + 'X.c(', 'func(a, b)'),
(partialmethod_code + 'X.d(', None),
('import contextlib\n@contextlib.contextmanager\ndef f(x): pass\nf(', 'f(x)'),
]
)
def test_tree_signature(Script, environment, code, expected):