diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index bea5ba985..e43495d7e 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -15,6 +15,8 @@ _promote = object() class _SpecialForm(object): def __getitem__(self, typeargs: Any) -> object: ... +Union: _SpecialForm = ... +Optional: _SpecialForm = ... Tuple: _SpecialForm = ... Generic: _SpecialForm = ... Protocol: _SpecialForm = ... @@ -53,20 +55,17 @@ def no_type_check_decorator(decorator: _C) -> _C: ... # Type aliases and type constructors -class TypeAlias: +class _Alias: # Class for defining generic aliases for library types. - def __init__(self, target_type: type) -> None: ... def __getitem__(self, typeargs: Any) -> Any: ... -Union = TypeAlias(object) -Optional = TypeAlias(object) -List = TypeAlias(object) -Dict = TypeAlias(object) -DefaultDict = TypeAlias(object) -Set = TypeAlias(object) -FrozenSet = TypeAlias(object) -Counter = TypeAlias(object) -Deque = TypeAlias(object) +List = _Alias() +Dict = _Alias() +DefaultDict = _Alias() +Set = _Alias() +FrozenSet = _Alias() +Counter = _Alias() +Deque = _Alias() # Predefined type variables. AnyStr = TypeVar('AnyStr', str, unicode) diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 6c4dcc253..046d0cf42 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -14,8 +14,10 @@ TypeVar = object() _promote = object() class _SpecialForm: - def __getitem__(self, typeargs: Any) -> Any: ... + def __getitem__(self, typeargs: Any) -> object: ... +Union: _SpecialForm = ... +Optional: _SpecialForm = ... Tuple: _SpecialForm = ... Generic: _SpecialForm = ... # Protocol is only present in 3.8 and later, but mypy needs it unconditionally @@ -61,8 +63,6 @@ class _Alias: # Class for defining generic aliases for library types. def __getitem__(self, typeargs: Any) -> Any: ... -Union = _Alias() -Optional = _Alias() List = _Alias() Dict = _Alias() DefaultDict = _Alias()