diff --git a/jedi/api/classes.py b/jedi/api/classes.py index 09ef432b..86453594 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -625,6 +625,9 @@ class Signature(Definition): return [ParamDefinition(self._evaluator, n) for n in self._signature.get_param_names(resolve_stars=True)] + def to_string(self): + return self._signature.to_string() + class CallSignature(Signature): """ diff --git a/test/test_evaluate/test_signature.py b/test/test_evaluate/test_signature.py index aa86413b..0bb5cbae 100644 --- a/test/test_evaluate/test_signature.py +++ b/test/test_evaluate/test_signature.py @@ -90,7 +90,7 @@ def test_tree_signature(Script, environment, code, expected): assert not Script(code).call_signatures() else: sig, = Script(code).call_signatures() - assert expected == sig._signature.to_string() + assert expected == sig.to_string() @pytest.mark.parametrize( @@ -180,7 +180,7 @@ def test_nested_signatures(Script, environment, combination, expected, skip_pre_ ''') code += 'z = ' + combination + '\nz(' sig, = Script(code).call_signatures() - computed = sig._signature.to_string() + computed = sig.to_string() if not re.match(r'\w+\(', expected): expected = '(' + expected + ')' assert expected == computed @@ -189,7 +189,7 @@ def test_nested_signatures(Script, environment, combination, expected, skip_pre_ def test_pow_signature(Script): # See github #1357 sigs = Script('pow(').call_signatures() - strings = {sig._signature.to_string() for sig in sigs} + strings = {sig.to_string() for sig in sigs} assert strings == {'pow(x: float, y: float, z: float, /) -> float', 'pow(x: float, y: float, /) -> float', 'pow(x: int, y: int, z: int, /) -> Any', @@ -228,7 +228,7 @@ def test_pow_signature(Script): ) def test_wraps_signature(Script, code, signature, skip_pre_python35): sigs = Script(code).call_signatures() - assert {sig._signature.to_string() for sig in sigs} == {signature} + assert {sig.to_string() for sig in sigs} == {signature} @pytest.mark.parametrize(