diff --git a/stdlib/types.pyi b/stdlib/types.pyi index fe443be27121..a1312447cb9e 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -16,8 +16,8 @@ from collections.abc import ( ValuesView, ) from importlib.machinery import ModuleSpec -from typing import Any, ClassVar, Literal, TypeVar, final, overload -from typing_extensions import ParamSpec, Self, TypeAliasType, TypeVarTuple, deprecated +from typing import Any, ClassVar, Generic, Literal, final, overload +from typing_extensions import ParamSpec, Self, TypeAliasType, TypeVar, TypeVarTuple, deprecated __all__ = [ "FunctionType", @@ -642,14 +642,17 @@ def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Await @overload def coroutine(func: _Fn) -> _Fn: ... -class GenericAlias: +# typically a type or type expression +_OriginT_co = TypeVar("_OriginT_co", bound=type | TypeAliasType, default=type | TypeAliasType, covariant=True) + +class GenericAlias(Generic[_OriginT_co]): @property - def __origin__(self) -> type | TypeAliasType: ... + def __origin__(self) -> _OriginT_co: ... @property def __args__(self) -> tuple[Any, ...]: ... @property def __parameters__(self) -> tuple[Any, ...]: ... - def __new__(cls, origin: type, args: Any, /) -> Self: ... + def __new__(cls, origin: _OriginT_co, args: Any, /) -> Self: ... def __getitem__(self, typeargs: Any, /) -> GenericAlias: ... def __eq__(self, value: object, /) -> bool: ... def __hash__(self) -> int: ...