Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit f52932c

Browse files
DetachHeadKotlinIsland
authored andcommitted
add _GenericAlias stub
1 parent 9064758 commit f52932c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

stdlib/typing.pyi

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,4 +872,54 @@ class ForwardRef:
872872
if sys.version_info >= (3, 10):
873873
def is_typeddict(tp: object) -> bool: ...
874874

875+
class _Final:
876+
"""Mixin to prohibit subclassing"""
877+
878+
def __init_subclass__(__cls, *args: object, **kwds: object): ...
879+
880+
class _BaseGenericAlias(_Final, _root=True):
881+
__origin__: type
882+
def __init__(self, origin: type, *, inst: bool = ..., name: str | None = ...) -> None:
883+
self._inst = inst
884+
self._name = name
885+
self.__origin__ = origin
886+
887+
_Params = Union[type, Tuple[type, ...]]
888+
889+
class _GenericAlias(_BaseGenericAlias, _root=True):
890+
def __init__( # pylint:disable=super-init-not-called
891+
self,
892+
origin: type,
893+
params: _Params, # pylint:disable=unused-argument
894+
*,
895+
inst: bool = ..., # pylint:disable=unused-argument
896+
name: str | None = ...,
897+
_typevar_types: Type[TypeVar] = ...,
898+
_paramspec_tvars: bool = ...,
899+
):
900+
self.__args__: Tuple[type, ...]
901+
self.__parameters__: Tuple[TypeVar, ...]
902+
self._typevar_types = _typevar_types
903+
self._paramspec_tvars = _paramspec_tvars
904+
self.__module__ = origin.__module__
905+
# def __eq__(self, other: object) -> bool:
906+
# ...
907+
def __hash__(self) -> int: ...
908+
def __or__(self, right: object) -> _SpecialForm: ...
909+
def __ror__(self, left: object) -> _SpecialForm: ...
910+
def __getitem__(self: TypeshedSelf, params: _Params) -> TypeshedSelf: ...
911+
def copy_with(self: TypeshedSelf, params: _Params) -> TypeshedSelf: ... # pylint:disable=no-self-use # pylint:disable=unused-argument
912+
# def __reduce__(self):
913+
# if self._name:
914+
# origin = globals()[self._name]
915+
# else:
916+
# origin = self.__origin__
917+
# args = tuple(self.__args__)
918+
# if len(args) == 1 and not isinstance(args[0], tuple):
919+
# args, = args
920+
# return operator.getitem, (origin, args)
921+
def __mro_entries__( # pylint:disable=no-self-use
922+
self, bases: Tuple[type, ...] # pylint:disable=unused-argument
923+
) -> Tuple[type, ...]: ...
924+
875925
def _type_repr(obj: object) -> str: ...

0 commit comments

Comments
 (0)