Open
Description
Generic type aliases are not currently supported for autocompletion. For context, for a codebase I'm developing, I'm working with a generic type alias that helps me handle TypeScript interface undefined
values (which differ from null
, a value that corresponds to Python's None
).
See below for a simple example of the problem.
from dataclasses import dataclass
from typing import TypeVar, Union
T = TypeVar("T")
MyType = Union[None, T]
d = {"t": "hello"}
@dataclass
class MyDataclass:
t: MyType[str]
result = MyDataclass(**d)
result.t.
To remain consistent with jedi's behavior concerning Union
types, this should provide completions for both string and None, but it completes nothing with version 0.17.2
. For comparison, things work fine for Optional
, which is basically a special case of Union[None, T]
:
from dataclasses import dataclass
from typing import Optional
d = {"t": "hello"}
@dataclass
class MyDataclass:
t: Optional[str]
result = MyDataclass(**d)
result.t.