Skip to content

Commit

Permalink
add _GenericAlias stub to typeshed
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead authored and KotlinIsland committed Jan 6, 2022
1 parent 1bf48b1 commit 132583c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions mypy/typeshed/stdlib/typing.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from _typeshed import Self
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
import sys
from abc import ABCMeta, abstractmethod
Expand Down Expand Up @@ -715,3 +716,49 @@ if sys.version_info >= (3, 7):

if sys.version_info >= (3, 10):
def is_typeddict(tp: Any) -> bool: ...

class _Final:
"""Mixin to prohibit subclassing"""

class _BaseGenericAlias(_Final, _root=True):
__origin__: type
def __init__(self, origin: type, *, inst: bool = ..., name: str | None = ...) -> None:
self._inst = inst
self._name = name
self.__origin__ = origin

_Params = Union[type, Tuple[type, ...]]

class _GenericAlias(_BaseGenericAlias, _root=True):
def __init__(
self,
origin: type,
params: _Params,
*,
inst: bool = ...,
name: str | None = ...,
_typevar_types: type[TypeVar] = ...,
_paramspec_tvars: bool = ...,
):
self.__args__: tuple[type, ...]
self.__parameters__: tuple[TypeVar, ...]
self._typevar_types = _typevar_types
self._paramspec_tvars = _paramspec_tvars
self.__module__ = origin.__module__
# def __eq__(self, other: object) -> bool:
# ...
def __hash__(self) -> int: ...
def __or__(self, right: object) -> _SpecialForm: ...
def __ror__(self, left: object) -> _SpecialForm: ...
def __getitem__(self: Self, params: _Params) -> Self: ...
def copy_with(self: Self, params: _Params) -> Self: ...
# def __reduce__(self):
# if self._name:
# origin = globals()[self._name]
# else:
# origin = self.__origin__
# args = tuple(self.__args__)
# if len(args) == 1 and not isinstance(args[0], tuple):
# args, = args
# return operator.getitem, (origin, args)
def __mro_entries__(self, bases: tuple[type, ...]) -> tuple[type, ...]: ...

0 comments on commit 132583c

Please sign in to comment.