typing: update and fix for py310 (#5287)

This commit is contained in:
Shantanu
2021-05-01 21:09:26 -07:00
committed by GitHub
parent 2d69d1a695
commit 3aa1f2d42f
2 changed files with 39 additions and 9 deletions

View File

@@ -20,6 +20,7 @@ from typing import (
Tuple,
Type as Type,
TypeVar,
Union,
ValuesView,
overload as overload,
)
@@ -96,9 +97,6 @@ if sys.version_info >= (3, 7):
Annotated: _SpecialForm = ...
_AnnotatedAlias: Any = ... # undocumented
# TypeAlias is a (non-subscriptable) special form.
class TypeAlias: ...
@runtime_checkable
class SupportsIndex(Protocol, metaclass=abc.ABCMeta):
@abc.abstractmethod
@@ -106,12 +104,26 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta):
# PEP 612 support for Python < 3.9
if sys.version_info >= (3, 10):
from typing import Concatenate as Concatenate, ParamSpec as ParamSpec
from typing import Concatenate as Concatenate, ParamSpec as ParamSpec, TypeAlias as TypeAlias, TypeGuard as TypeGuard
else:
class ParamSpecArgs:
__origin__: ParamSpec
def __init__(self, origin: ParamSpec) -> None: ...
class ParamSpecKwargs:
__origin__: ParamSpec
def __init__(self, origin: ParamSpec) -> None: ...
class ParamSpec:
__name__: str
def __init__(self, name: str) -> None: ...
__bound__: Optional[Type[Any]]
__covariant__: bool
__contravariant__: bool
def __init__(
self, name: str, bound: Union[None, Type[Any], str] = ..., contravariant: bool = ..., covariant: bool = ...
) -> None: ...
@property
def args(self) -> ParamSpecArgs: ...
@property
def kwargs(self) -> ParamSpecKwargs: ...
Concatenate: _SpecialForm = ...
# PEP 647
TypeGuard: _SpecialForm = ...
TypeAlias: _SpecialForm = ...
TypeGuard: _SpecialForm = ...