diff --git a/AUTHORS.txt b/AUTHORS.txt index 4776d16d..0d4ac10e 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -50,5 +50,6 @@ Anton Zub (@zabulazza) Maksim Novikov (@m-novikov) Tobias Rzepka (@TobiasRzepka) micbou (@micbou) +Dima Gerasimov (@karlicoss) Note: (@user) means a github user name. diff --git a/jedi/parser_utils.py b/jedi/parser_utils.py index e6302653..4ceced5c 100644 --- a/jedi/parser_utils.py +++ b/jedi/parser_utils.py @@ -156,7 +156,11 @@ def get_call_signature(funcdef, width=72, call_string=None): p = '(' + ''.join(param.get_code() for param in funcdef.get_params()).strip() + ')' else: p = funcdef.children[2].get_code() - code = call_string + p + if funcdef.annotation: + rtype = " ->" + funcdef.annotation.get_code() + else: + rtype = "" + code = call_string + p + rtype return '\n'.join(textwrap.wrap(code, width)) diff --git a/test/test_parso_integration/test_parser_utils.py b/test/test_parso_integration/test_parser_utils.py index c207fdd6..6cfd702b 100644 --- a/test/test_parso_integration/test_parser_utils.py +++ b/test/test_parso_integration/test_parser_utils.py @@ -75,7 +75,8 @@ def test_hex_values_in_docstring(): @pytest.mark.parametrize( 'code,call_signature', [ - ('def my_function(x, y, z) -> str:\n return', 'my_function(x, y, z)'), + ('def my_function(x, typed: Type, z):\n return', 'my_function(x, typed: Type, z)'), + ('def my_function(x, y, z) -> str:\n return', 'my_function(x, y, z) -> str'), ('lambda x, y, z: x + y * z\n', '(x, y, z)') ]) def test_get_call_signature(code, call_signature):