mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-10 02:19:18 +08:00
typing: make Generic definition reflect runtime (#14583)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -466,7 +466,6 @@ typing._Final.__init_subclass__
|
||||
typing\.Protocol
|
||||
typing(_extensions)?\._TypedDict
|
||||
typing(_extensions)?\.Any.*
|
||||
typing(_extensions)?\.Generic
|
||||
typing(_extensions)?\.TypedDict
|
||||
typing_extensions\.ParamSpec.*
|
||||
typing_extensions\.TypeVar.*
|
||||
|
||||
+14
-1
@@ -235,7 +235,6 @@ class _SpecialForm(_Final):
|
||||
def __ror__(self, other: Any) -> _SpecialForm: ...
|
||||
|
||||
Union: _SpecialForm
|
||||
Generic: _SpecialForm
|
||||
Protocol: _SpecialForm
|
||||
Callable: _SpecialForm
|
||||
Type: _SpecialForm
|
||||
@@ -440,6 +439,20 @@ Annotated: _SpecialForm
|
||||
# Predefined type variables.
|
||||
AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001
|
||||
|
||||
@type_check_only
|
||||
class _Generic:
|
||||
if sys.version_info < (3, 12):
|
||||
__slots__ = ()
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
@classmethod
|
||||
def __class_getitem__(cls, args: TypeVar | ParamSpec | tuple[TypeVar | ParamSpec, ...]) -> _Final: ...
|
||||
else:
|
||||
@classmethod
|
||||
def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ...
|
||||
|
||||
Generic: type[_Generic]
|
||||
|
||||
class _ProtocolMeta(ABCMeta):
|
||||
if sys.version_info >= (3, 12):
|
||||
def __init__(cls, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user