diff --git a/AUTHORS.txt b/AUTHORS.txt index f28e1c90..8c3df84f 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -58,6 +58,7 @@ Code Contributors - Lior Goldberg (@goldberglior) - Ryan Clary (@mrclary) - Max Mäusezahl (@mmaeusezahl) +- Vladislav Serebrennikov (@endilll) And a few more "anonymous" contributors. diff --git a/jedi/inference/compiled/access.py b/jedi/inference/compiled/access.py index 99bd843c..a02b548b 100644 --- a/jedi/inference/compiled/access.py +++ b/jedi/inference/compiled/access.py @@ -485,9 +485,9 @@ class DirectObjectAccess(object): return inspect.isclass(self._obj) and self._obj != type def _annotation_to_str(self, annotation): - if isinstance(annotation, type): - return str(annotation.__name__) - return str(annotation) + if py_version < 30: + return '' + return inspect.formatannotation(annotation) def get_signature_params(self): return [ diff --git a/test/test_inference/test_mixed.py b/test/test_inference/test_mixed.py index 7f3c387f..fce1929f 100644 --- a/test/test_inference/test_mixed.py +++ b/test/test_inference/test_mixed.py @@ -102,3 +102,14 @@ def test_signature(): s, = jedi.Interpreter('some_signature', [locals()]).goto() assert s.docstring() == 'some_signature(*, bar=1)' + + +@pytest.mark.skipif(sys.version_info[0:2] < (3, 5), reason="Typing was introduced in Python 3.5") +def test_compiled_signature_annotation_string(): + import typing + def func(x: typing.Type, y: typing.Union[typing.Type, int]): pass + func.__name__ = 'not_func' + + s, = jedi.Interpreter('func()', [locals()]).get_signatures(1, 5) + assert s.params[0].description == 'param x: Type' + assert s.params[1].description == 'param y: Union[Type, int]'