Skip to content

Commit f536953

Browse files
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 <[email protected]>
1 parent e173cbe commit f536953

File tree

1 file changed

+67
-26
lines changed

1 file changed

+67
-26
lines changed

stdlib/typing_extensions.pyi

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import _typeshed
22
import abc
33
import collections
44
import sys
5+
import typing
56
from _collections_abc import dict_items, dict_keys, dict_values
6-
from _typeshed import IdentityFunction
7+
from _typeshed import IdentityFunction, Incomplete
78
from collections.abc import Iterable
89
from typing import ( # noqa: Y022,Y027,Y039
910
TYPE_CHECKING as TYPE_CHECKING,
10-
Any,
11+
Any as Any,
1112
AsyncContextManager as AsyncContextManager,
1213
AsyncGenerator as AsyncGenerator,
1314
AsyncIterable as AsyncIterable,
@@ -27,13 +28,13 @@ from typing import ( # noqa: Y022,Y027,Y039
2728
Sequence,
2829
Text as Text,
2930
Type as Type,
30-
TypeVar,
3131
_Alias,
3232
overload as overload,
3333
type_check_only,
3434
)
3535

3636
__all__ = [
37+
"Any",
3738
"ClassVar",
3839
"Concatenate",
3940
"Final",
@@ -43,6 +44,7 @@ __all__ = [
4344
"ParamSpecKwargs",
4445
"Self",
4546
"Type",
47+
"TypeVar",
4648
"TypeVarTuple",
4749
"Unpack",
4850
"Awaitable",
@@ -70,6 +72,7 @@ __all__ = [
7072
"Literal",
7173
"NewType",
7274
"overload",
75+
"override",
7376
"Protocol",
7477
"reveal_type",
7578
"runtime",
@@ -89,9 +92,9 @@ __all__ = [
8992
"get_type_hints",
9093
]
9194

92-
_T = TypeVar("_T")
93-
_F = TypeVar("_F", bound=Callable[..., Any])
94-
_TC = TypeVar("_TC", bound=Type[object])
95+
_T = typing.TypeVar("_T")
96+
_F = typing.TypeVar("_F", bound=Callable[..., Any])
97+
_TC = typing.TypeVar("_TC", bound=Type[object])
9598

9699
# unfortunately we have to duplicate this class definition from typing.pyi or we break pytype
97100
class _SpecialForm:
@@ -167,7 +170,6 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta):
167170
if sys.version_info >= (3, 10):
168171
from typing import (
169172
Concatenate as Concatenate,
170-
ParamSpec as ParamSpec,
171173
ParamSpecArgs as ParamSpecArgs,
172174
ParamSpecKwargs as ParamSpecKwargs,
173175
TypeAlias as TypeAlias,
@@ -183,18 +185,6 @@ else:
183185
__origin__: ParamSpec
184186
def __init__(self, origin: ParamSpec) -> None: ...
185187

186-
class ParamSpec:
187-
__name__: str
188-
__bound__: type[Any] | None
189-
__covariant__: bool
190-
__contravariant__: bool
191-
def __init__(
192-
self, name: str, *, bound: None | type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ...
193-
) -> None: ...
194-
@property
195-
def args(self) -> ParamSpecArgs: ...
196-
@property
197-
def kwargs(self) -> ParamSpecKwargs: ...
198188
Concatenate: _SpecialForm
199189
TypeAlias: _SpecialForm
200190
TypeGuard: _SpecialForm
@@ -210,7 +200,6 @@ if sys.version_info >= (3, 11):
210200
NotRequired as NotRequired,
211201
Required as Required,
212202
Self as Self,
213-
TypeVarTuple as TypeVarTuple,
214203
Unpack as Unpack,
215204
assert_never as assert_never,
216205
assert_type as assert_type,
@@ -233,12 +222,6 @@ else:
233222
LiteralString: _SpecialForm
234223
Unpack: _SpecialForm
235224

236-
@final
237-
class TypeVarTuple:
238-
__name__: str
239-
def __init__(self, name: str) -> None: ...
240-
def __iter__(self) -> Any: ... # Unpack[Self]
241-
242225
def dataclass_transform(
243226
*,
244227
eq_default: bool = ...,
@@ -268,3 +251,61 @@ else:
268251
def _asdict(self) -> collections.OrderedDict[str, Any]: ...
269252

270253
def _replace(self: _typeshed.Self, **kwargs: Any) -> _typeshed.Self: ...
254+
255+
# New things in 3.xx
256+
# The `default` parameter was added to TypeVar, ParamSpec, and TypeVarTuple (PEP 696)
257+
# The `infer_variance` parameter was added to TypeVar (PEP 695)
258+
# typing_extensions.override (PEP 698)
259+
@final
260+
class TypeVar:
261+
__name__: str
262+
__bound__: Any | None
263+
__constraints__: tuple[Any, ...]
264+
__covariant__: bool
265+
__contravariant__: bool
266+
__default__: Any | None
267+
def __init__(
268+
self,
269+
name: str,
270+
*constraints: Any,
271+
bound: Any | None = ...,
272+
covariant: bool = ...,
273+
contravariant: bool = ...,
274+
default: Any | None = ...,
275+
infer_variance: bool = ...,
276+
) -> None: ...
277+
if sys.version_info >= (3, 10):
278+
def __or__(self, right: Any) -> _SpecialForm: ...
279+
def __ror__(self, left: Any) -> _SpecialForm: ...
280+
if sys.version_info >= (3, 11):
281+
def __typing_subst__(self, arg: Incomplete) -> Incomplete: ...
282+
283+
@final
284+
class ParamSpec:
285+
__name__: str
286+
__bound__: type[Any] | None
287+
__covariant__: bool
288+
__contravariant__: bool
289+
__default__: type[Any] | None
290+
def __init__(
291+
self,
292+
name: str,
293+
*,
294+
bound: None | type[Any] | str = ...,
295+
contravariant: bool = ...,
296+
covariant: bool = ...,
297+
default: type[Any] | str | None = ...,
298+
) -> None: ...
299+
@property
300+
def args(self) -> ParamSpecArgs: ...
301+
@property
302+
def kwargs(self) -> ParamSpecKwargs: ...
303+
304+
@final
305+
class TypeVarTuple:
306+
__name__: str
307+
__default__: Any | None
308+
def __init__(self, name: str, *, default: Any | None = ...) -> None: ...
309+
def __iter__(self) -> Any: ... # Unpack[Self]
310+
311+
def override(__arg: _F) -> _F: ...

0 commit comments

Comments
 (0)