1
0
forked from VimPlug/jedi

Remove the word 'class' from annotation_string

Currently, 'foo(x: int)' results with annotation_string="<class 'int'>".
Change this to 'int'.
This commit is contained in:
Lior Goldberg
2020-02-20 00:44:35 +02:00
committed by Dave Halter
parent c4cf0d78e1
commit 1874e9be81
3 changed files with 12 additions and 2 deletions

View File

@@ -484,6 +484,11 @@ class DirectObjectAccess(object):
def needs_type_completions(self):
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)
def get_signature_params(self):
return [
SignatureParam(
@@ -493,7 +498,7 @@ class DirectObjectAccess(object):
default_string=repr(p.default),
has_annotation=p.annotation is not p.empty,
annotation=self._create_access_path(p.annotation),
annotation_string=str(p.annotation),
annotation_string=self._annotation_to_str(p.annotation),
kind_name=str(p.kind)
) for p in self._get_signature().parameters.values()
]