Skip to content

generic GenericAlias #13941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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: ...
Expand Down