diff --git a/jedi/evaluate/context/instance.py b/jedi/evaluate/context/instance.py index 22b8c977..17e0382e 100644 --- a/jedi/evaluate/context/instance.py +++ b/jedi/evaluate/context/instance.py @@ -400,7 +400,7 @@ class BoundMethod(FunctionMixin, ContextWrapper): return function_execution.infer() def get_signatures(self): - return [sig.bind(self) for sig in self._wrapped_context.get_signatures()] + return [sig.bind(self) for sig in super(BoundMethod, self).get_signatures()] def __repr__(self): return '<%s: %s>' % (self.__class__.__name__, self._wrapped_context) diff --git a/test/test_evaluate/test_signature.py b/test/test_evaluate/test_signature.py index 5a4e2423..3cd9cf59 100644 --- a/test/test_evaluate/test_signature.py +++ b/test/test_evaluate/test_signature.py @@ -1,5 +1,6 @@ from textwrap import dedent from operator import ge, lt +import re import pytest @@ -103,11 +104,16 @@ def test_tree_signature(Script, environment, code, expected): # Non functions ('full_redirect(lambda x, y: ...)', 'y'), - ('full_redirect(C)', 'z, *c'), - ('full_redirect(C())', 'y'), ('full_redirect()', '*args, **kwargs'), ('full_redirect(1)', '*args, **kwargs'), + # Classes / inheritance + ('full_redirect(C)', 'z, *c'), + ('full_redirect(C())', 'y'), + ('D', 'D(x, ly)'), + ('D()', 'D(x, y)'), + ('D().foo', 'foo(a, *, bar, z, **kwargs)'), + # Merging ('two_redirects(simple, simple)', 'a, b, *, c'), ('two_redirects(simple2, simple2)', 'x'), @@ -162,11 +168,22 @@ def test_nested_signatures(Script, environment, combination, expected, skip_pre_ class C: def __init__(self, a, z, *c): ... def __call__(self, x, y): ... + + def foo(self, bar, z, **kwargs): ... + + class D(C): + def __init__(self, *args): + super().foo(*args) + + def foo(self, a, **kwargs): + super().foo(**kwargs) ''') code += 'z = ' + combination + '\nz(' sig, = Script(code).call_signatures() computed = sig._signature.to_string() - assert '(' + expected + ')' == computed + if not re.match('\w+\(', expected): + expected = '(' + expected + ')' + assert expected == computed def test_pow_signature(Script):