1
0
forked from VimPlug/jedi

Make Union/Optional works with compiled objects

This commit is contained in:
Dave Halter
2020-01-10 13:34:10 +01:00
parent ba7776c0d9
commit cac73f2d44
3 changed files with 23 additions and 1 deletions

View File

@@ -484,6 +484,19 @@ class DirectObjectAccess(object):
op = _OPERATORS[operator]
return self._create_access_path(op(self._obj, other_access._obj))
def get_annotation_name_and_args(self):
"""
Returns Tuple[Optional[str], Tuple[AccessPath, ...]]
"""
if sys.version_info < (3, 5):
return None, ()
import typing
args = typing.get_args(self._obj)
origin = typing.get_origin(self._obj)
name = None if origin is None else str(origin)
return name, tuple(self._create_access_path(arg) for arg in args)
def needs_type_completions(self):
return inspect.isclass(self._obj) and self._obj != type