Skip to content

Commit bedf520

Browse files
typing(_extensions) updates for 3.11 (#7643)
1 parent 499e74c commit bedf520

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

stdlib/typing.pyi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ if sys.version_info >= (3, 11):
2222
"ForwardRef",
2323
"Generic",
2424
"Literal",
25+
"LiteralString",
26+
"NotRequired",
2527
"Optional",
2628
"ParamSpec",
2729
"Protocol",
30+
"Required",
2831
"Tuple",
2932
"Type",
3033
"TypeVar",
@@ -84,9 +87,11 @@ if sys.version_info >= (3, 11):
8487
"assert_never",
8588
"assert_type",
8689
"cast",
90+
"clear_overloads",
8791
"final",
8892
"get_args",
8993
"get_origin",
94+
"get_overloads",
9095
"get_type_hints",
9196
"is_typeddict",
9297
"Never",
@@ -528,6 +533,9 @@ if sys.version_info >= (3, 11):
528533
Self: _SpecialForm
529534
Never: _SpecialForm = ...
530535
Unpack: _SpecialForm
536+
Required: _SpecialForm
537+
NotRequired: _SpecialForm
538+
LiteralString: _SpecialForm
531539

532540
class TypeVarTuple:
533541
__name__: str
@@ -1180,6 +1188,8 @@ if sys.version_info >= (3, 11):
11801188
def reveal_type(__obj: _T) -> _T: ...
11811189
def assert_never(__arg: Never) -> Never: ...
11821190
def assert_type(__val: _T, __typ: Any) -> _T: ...
1191+
def clear_overloads() -> None: ...
1192+
def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ...
11831193

11841194
# Type constructors
11851195

stdlib/typing_extensions.pyi

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ from typing import ( # noqa: Y022,Y027
2222
Mapping,
2323
NewType as NewType,
2424
NoReturn as NoReturn,
25+
Sequence,
2526
Text as Text,
2627
Type as Type,
2728
TypeVar,
@@ -76,8 +77,10 @@ __all__ = [
7677
"NoReturn",
7778
"Required",
7879
"NotRequired",
80+
"clear_overloads",
7981
"get_args",
8082
"get_origin",
83+
"get_overloads",
8184
"get_type_hints",
8285
]
8386

@@ -188,10 +191,17 @@ else:
188191
# New things in 3.11
189192
if sys.version_info >= (3, 11):
190193
from typing import (
194+
LiteralString as LiteralString,
191195
Never as Never,
196+
NotRequired as NotRequired,
197+
Required as Required,
192198
Self as Self,
199+
TypeVarTuple as TypeVarTuple,
200+
Unpack as Unpack,
193201
assert_never as assert_never,
194202
assert_type as assert_type,
203+
clear_overloads as clear_overloads,
204+
get_overloads as get_overloads,
195205
reveal_type as reveal_type,
196206
)
197207
else:
@@ -200,23 +210,26 @@ else:
200210
def reveal_type(__obj: _T) -> _T: ...
201211
def assert_never(__arg: NoReturn) -> NoReturn: ...
202212
def assert_type(__val: _T, __typ: Any) -> _T: ...
213+
def clear_overloads() -> None: ...
214+
def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ...
203215

204-
# Experimental (hopefully these will be in 3.11)
205-
Required: _SpecialForm
206-
NotRequired: _SpecialForm
207-
LiteralString: _SpecialForm
208-
Unpack: _SpecialForm
216+
Required: _SpecialForm
217+
NotRequired: _SpecialForm
218+
LiteralString: _SpecialForm
219+
Unpack: _SpecialForm
209220

210-
@final
211-
class TypeVarTuple:
212-
__name__: str
213-
def __init__(self, name: str) -> None: ...
214-
def __iter__(self) -> Any: ... # Unpack[Self]
221+
@final
222+
class TypeVarTuple:
223+
__name__: str
224+
def __init__(self, name: str) -> None: ...
225+
def __iter__(self) -> Any: ... # Unpack[Self]
215226

227+
# Experimental (hopefully these will be in 3.11)
216228
def dataclass_transform(
217229
*,
218230
eq_default: bool = ...,
219231
order_default: bool = ...,
220232
kw_only_default: bool = ...,
221-
field_descriptors: tuple[type[Any] | Callable[..., Any], ...] = ...,
233+
field_specifiers: tuple[type[Any] | Callable[..., Any], ...] = ...,
234+
**kwargs: object,
222235
) -> Callable[[_T], _T]: ...

0 commit comments

Comments
 (0)