Update for typing_extensions 4.4.0 (#8821)

* TypeVarLike default parameters (PEP 696)
* TypeVarLike auto_inference parameter (PEP 695)
* Add typing_extensions.override (PEP 698)
* Add typing_extensions.Any

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Marc Mueller
2022-10-07 01:17:57 +02:00
committed by GitHub
parent e173cbe7b6
commit f5369536b9

View File

@@ -2,12 +2,13 @@ import _typeshed
import abc
import collections
import sys
import typing
from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import IdentityFunction
from _typeshed import IdentityFunction, Incomplete
from collections.abc import Iterable
from typing import ( # noqa: Y022,Y027,Y039
TYPE_CHECKING as TYPE_CHECKING,
Any,
Any as Any,
AsyncContextManager as AsyncContextManager,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
@@ -27,13 +28,13 @@ from typing import ( # noqa: Y022,Y027,Y039
Sequence,
Text as Text,
Type as Type,
TypeVar,
_Alias,
overload as overload,
type_check_only,
)
__all__ = [
"Any",
"ClassVar",
"Concatenate",
"Final",
@@ -43,6 +44,7 @@ __all__ = [
"ParamSpecKwargs",
"Self",
"Type",
"TypeVar",
"TypeVarTuple",
"Unpack",
"Awaitable",
@@ -70,6 +72,7 @@ __all__ = [
"Literal",
"NewType",
"overload",
"override",
"Protocol",
"reveal_type",
"runtime",
@@ -89,9 +92,9 @@ __all__ = [
"get_type_hints",
]
_T = TypeVar("_T")
_F = TypeVar("_F", bound=Callable[..., Any])
_TC = TypeVar("_TC", bound=Type[object])
_T = typing.TypeVar("_T")
_F = typing.TypeVar("_F", bound=Callable[..., Any])
_TC = typing.TypeVar("_TC", bound=Type[object])
# unfortunately we have to duplicate this class definition from typing.pyi or we break pytype
class _SpecialForm:
@@ -167,7 +170,6 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta):
if sys.version_info >= (3, 10):
from typing import (
Concatenate as Concatenate,
ParamSpec as ParamSpec,
ParamSpecArgs as ParamSpecArgs,
ParamSpecKwargs as ParamSpecKwargs,
TypeAlias as TypeAlias,
@@ -183,18 +185,6 @@ else:
__origin__: ParamSpec
def __init__(self, origin: ParamSpec) -> None: ...
class ParamSpec:
__name__: str
__bound__: type[Any] | None
__covariant__: bool
__contravariant__: bool
def __init__(
self, name: str, *, bound: None | type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ...
) -> None: ...
@property
def args(self) -> ParamSpecArgs: ...
@property
def kwargs(self) -> ParamSpecKwargs: ...
Concatenate: _SpecialForm
TypeAlias: _SpecialForm
TypeGuard: _SpecialForm
@@ -210,7 +200,6 @@ if sys.version_info >= (3, 11):
NotRequired as NotRequired,
Required as Required,
Self as Self,
TypeVarTuple as TypeVarTuple,
Unpack as Unpack,
assert_never as assert_never,
assert_type as assert_type,
@@ -233,12 +222,6 @@ else:
LiteralString: _SpecialForm
Unpack: _SpecialForm
@final
class TypeVarTuple:
__name__: str
def __init__(self, name: str) -> None: ...
def __iter__(self) -> Any: ... # Unpack[Self]
def dataclass_transform(
*,
eq_default: bool = ...,
@@ -268,3 +251,61 @@ else:
def _asdict(self) -> collections.OrderedDict[str, Any]: ...
def _replace(self: _typeshed.Self, **kwargs: Any) -> _typeshed.Self: ...
# New things in 3.xx
# The `default` parameter was added to TypeVar, ParamSpec, and TypeVarTuple (PEP 696)
# The `infer_variance` parameter was added to TypeVar (PEP 695)
# typing_extensions.override (PEP 698)
@final
class TypeVar:
__name__: str
__bound__: Any | None
__constraints__: tuple[Any, ...]
__covariant__: bool
__contravariant__: bool
__default__: Any | None
def __init__(
self,
name: str,
*constraints: Any,
bound: Any | None = ...,
covariant: bool = ...,
contravariant: bool = ...,
default: Any | None = ...,
infer_variance: bool = ...,
) -> None: ...
if sys.version_info >= (3, 10):
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Incomplete) -> Incomplete: ...
@final
class ParamSpec:
__name__: str
__bound__: type[Any] | None
__covariant__: bool
__contravariant__: bool
__default__: type[Any] | None
def __init__(
self,
name: str,
*,
bound: None | type[Any] | str = ...,
contravariant: bool = ...,
covariant: bool = ...,
default: type[Any] | str | None = ...,
) -> None: ...
@property
def args(self) -> ParamSpecArgs: ...
@property
def kwargs(self) -> ParamSpecKwargs: ...
@final
class TypeVarTuple:
__name__: str
__default__: Any | None
def __init__(self, name: str, *, default: Any | None = ...) -> None: ...
def __iter__(self) -> Any: ... # Unpack[Self]
def override(__arg: _F) -> _F: ...