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

Commit ea8484e

Browse files
DetachHeadKotlinIsland
authored andcommitted
add _GenericAlias stub
1 parent 2491774 commit ea8484e

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
@@ -1260,3 +1260,53 @@ if sys.version_info >= (3, 7):
12601260

12611261
if sys.version_info >= (3, 10):
12621262
def is_typeddict(tp: object) -> bool: ...
1263+
1264+
class _Final:
1265+
"""Mixin to prohibit subclassing"""
1266+
1267+
def __init_subclass__(__cls, *args: object, **kwds: object): ...
1268+
1269+
class _BaseGenericAlias(_Final, _root=True):
1270+
__origin__: type
1271+
def __init__(self, origin: type, *, inst: bool = ..., name: str | None = ...) -> None:
1272+
self._inst = inst
1273+
self._name = name
1274+
self.__origin__ = origin
1275+
1276+
_Params = Union[type, Tuple[type, ...]]
1277+
1278+
class _GenericAlias(_BaseGenericAlias, _root=True):
1279+
def __init__( # pylint:disable=super-init-not-called
1280+
self,
1281+
origin: type,
1282+
params: _Params, # pylint:disable=unused-argument
1283+
*,
1284+
inst: bool = ..., # pylint:disable=unused-argument
1285+
name: str | None = ...,
1286+
_typevar_types: Type[TypeVar] = ...,
1287+
_paramspec_tvars: bool = ...,
1288+
):
1289+
self.__args__: Tuple[type, ...]
1290+
self.__parameters__: Tuple[TypeVar, ...]
1291+
self._typevar_types = _typevar_types
1292+
self._paramspec_tvars = _paramspec_tvars
1293+
self.__module__ = origin.__module__
1294+
# def __eq__(self, other: object) -> bool:
1295+
# ...
1296+
def __hash__(self) -> int: ...
1297+
def __or__(self, right: object) -> _SpecialForm: ...
1298+
def __ror__(self, left: object) -> _SpecialForm: ...
1299+
def __getitem__(self: TypeshedSelf, params: _Params) -> TypeshedSelf: ...
1300+
def copy_with(self: TypeshedSelf, params: _Params) -> TypeshedSelf: ... # pylint:disable=no-self-use # pylint:disable=unused-argument
1301+
# def __reduce__(self):
1302+
# if self._name:
1303+
# origin = globals()[self._name]
1304+
# else:
1305+
# origin = self.__origin__
1306+
# args = tuple(self.__args__)
1307+
# if len(args) == 1 and not isinstance(args[0], tuple):
1308+
# args, = args
1309+
# return operator.getitem, (origin, args)
1310+
def __mro_entries__( # pylint:disable=no-self-use
1311+
self, bases: Tuple[type, ...] # pylint:disable=unused-argument
1312+
) -> Tuple[type, ...]: ...

0 commit comments

Comments
 (0)