Skip to content

Commit 7dd2485

Browse files
New additions to typing, typing_extensions (#7169)
1 parent b0202f7 commit 7dd2485

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

stdlib/typing.pyi

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ if sys.version_info >= (3, 8):
6666
# TypedDict is a (non-subscriptable) special form.
6767
TypedDict: object
6868

69+
if sys.version_info >= (3, 11):
70+
Self: _SpecialForm
71+
Never: _SpecialForm = ...
72+
6973
if sys.version_info < (3, 7):
7074
class GenericMeta(type): ...
7175

@@ -697,6 +701,10 @@ def cast(typ: str, val: Any) -> Any: ...
697701
@overload
698702
def cast(typ: object, val: Any) -> Any: ...
699703

704+
if sys.version_info >= (3, 11):
705+
def reveal_type(__obj: _T) -> _T: ...
706+
def assert_never(__arg: Never) -> Never: ...
707+
700708
# Type constructors
701709

702710
class NamedTuple(tuple[Any, ...]):

stdlib/typing_extensions.pyi

+22-4
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ def runtime_checkable(cls: _TC) -> _TC: ...
5353
# This alias for above is kept here for backwards compatibility.
5454
runtime = runtime_checkable
5555
Final: _SpecialForm
56-
Self: _SpecialForm
57-
Required: _SpecialForm
58-
NotRequired: _SpecialForm
5956

6057
def final(f: _F) -> _F: ...
6158

@@ -103,7 +100,7 @@ class SupportsIndex(Protocol, metaclass=abc.ABCMeta):
103100
@abc.abstractmethod
104101
def __index__(self) -> int: ...
105102

106-
# PEP 612 support for Python < 3.9
103+
# New things in 3.10
107104
if sys.version_info >= (3, 10):
108105
from typing import (
109106
Concatenate as Concatenate,
@@ -137,3 +134,24 @@ else:
137134
TypeAlias: _SpecialForm
138135
TypeGuard: _SpecialForm
139136
def is_typeddict(tp: object) -> bool: ...
137+
138+
# New things in 3.11
139+
if sys.version_info >= (3, 11):
140+
from typing import Never as Never, Self as Self, assert_never as assert_never, reveal_type as reveal_type
141+
else:
142+
Self: _SpecialForm
143+
Never: _SpecialForm
144+
def reveal_type(__obj: _T) -> _T: ...
145+
def assert_never(__arg: NoReturn) -> NoReturn: ...
146+
147+
# Experimental (hopefully these will be in 3.11)
148+
Required: _SpecialForm
149+
NotRequired: _SpecialForm
150+
151+
def dataclass_transform(
152+
*,
153+
eq_default: bool = ...,
154+
order_default: bool = ...,
155+
kw_only_default: bool = ...,
156+
field_descriptors: tuple[type[Any] | Callable[..., Any], ...] = ...,
157+
) -> Callable[[_T], _T]: ...

0 commit comments

Comments
 (0)