Skip to content

Commit f577c4c

Browse files
Update typing_extensions for 4.7.* (#10344)
1 parent 65cb373 commit f577c4c

File tree

7 files changed

+152
-70
lines changed

7 files changed

+152
-70
lines changed

requirements-tests.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ stubdefaulter==0.1.0
2121
termcolor>=2.3
2222
tomli==2.0.1
2323
tomlkit==0.11.8
24-
typing-extensions==4.6.3
24+
typing_extensions
2525

2626
# Type stubs used to type check our scripts.
2727
types-pyyaml>=6.0.12.7

stdlib/typing.pyi

+4
Original file line numberDiff line numberDiff line change
@@ -956,3 +956,7 @@ if sys.version_info >= (3, 12):
956956
if sys.version_info >= (3, 10):
957957
def __or__(self, right: Any) -> _SpecialForm: ...
958958
def __ror__(self, left: Any) -> _SpecialForm: ...
959+
960+
if sys.version_info >= (3, 13):
961+
def is_protocol(__tp: type) -> bool: ...
962+
def get_protocol_members(__tp: type) -> frozenset[str]: ...

stdlib/typing_extensions.pyi

+83-5
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,68 @@ import sys
44
import typing
55
from _collections_abc import dict_items, dict_keys, dict_values
66
from _typeshed import IdentityFunction, Incomplete
7-
from collections.abc import Iterable
8-
from typing import ( # noqa: Y022,Y039
7+
from typing import ( # noqa: Y022,Y037,Y038,Y039
8+
IO as IO,
99
TYPE_CHECKING as TYPE_CHECKING,
10+
AbstractSet as AbstractSet,
1011
Any as Any,
12+
AnyStr as AnyStr,
1113
AsyncContextManager as AsyncContextManager,
1214
AsyncGenerator as AsyncGenerator,
1315
AsyncIterable as AsyncIterable,
1416
AsyncIterator as AsyncIterator,
1517
Awaitable as Awaitable,
16-
Callable,
18+
BinaryIO as BinaryIO,
19+
Callable as Callable,
1720
ChainMap as ChainMap,
1821
ClassVar as ClassVar,
22+
Collection as Collection,
23+
Container as Container,
1924
ContextManager as ContextManager,
2025
Coroutine as Coroutine,
2126
Counter as Counter,
2227
DefaultDict as DefaultDict,
2328
Deque as Deque,
24-
Mapping,
29+
Dict as Dict,
30+
ForwardRef as ForwardRef,
31+
FrozenSet as FrozenSet,
32+
Generator as Generator,
33+
Generic as Generic,
34+
Hashable as Hashable,
35+
ItemsView as ItemsView,
36+
Iterable as Iterable,
37+
Iterator as Iterator,
38+
KeysView as KeysView,
39+
List as List,
40+
Mapping as Mapping,
41+
MappingView as MappingView,
42+
Match as Match,
43+
MutableMapping as MutableMapping,
44+
MutableSequence as MutableSequence,
45+
MutableSet as MutableSet,
2546
NoReturn as NoReturn,
26-
Sequence,
47+
Optional as Optional,
48+
Pattern as Pattern,
49+
Reversible as Reversible,
50+
Sequence as Sequence,
51+
Set as Set,
52+
Sized as Sized,
2753
SupportsAbs as SupportsAbs,
2854
SupportsBytes as SupportsBytes,
2955
SupportsComplex as SupportsComplex,
3056
SupportsFloat as SupportsFloat,
3157
SupportsInt as SupportsInt,
3258
SupportsRound as SupportsRound,
3359
Text as Text,
60+
TextIO as TextIO,
61+
Tuple as Tuple,
3462
Type as Type,
63+
Union as Union,
64+
ValuesView as ValuesView,
3565
_Alias,
66+
cast as cast,
67+
no_type_check as no_type_check,
68+
no_type_check_decorator as no_type_check_decorator,
3669
overload as overload,
3770
type_check_only,
3871
)
@@ -109,6 +142,45 @@ __all__ = [
109142
"get_original_bases",
110143
"get_overloads",
111144
"get_type_hints",
145+
"AbstractSet",
146+
"AnyStr",
147+
"BinaryIO",
148+
"Callable",
149+
"Collection",
150+
"Container",
151+
"Dict",
152+
"ForwardRef",
153+
"FrozenSet",
154+
"Generator",
155+
"Generic",
156+
"Hashable",
157+
"IO",
158+
"ItemsView",
159+
"Iterable",
160+
"Iterator",
161+
"KeysView",
162+
"List",
163+
"Mapping",
164+
"MappingView",
165+
"Match",
166+
"MutableMapping",
167+
"MutableSequence",
168+
"MutableSet",
169+
"Optional",
170+
"Pattern",
171+
"Reversible",
172+
"Sequence",
173+
"Set",
174+
"Sized",
175+
"TextIO",
176+
"Tuple",
177+
"Union",
178+
"ValuesView",
179+
"cast",
180+
"get_protocol_members",
181+
"is_protocol",
182+
"no_type_check",
183+
"no_type_check_decorator",
112184
]
113185

114186
_T = typing.TypeVar("_T")
@@ -403,3 +475,9 @@ else:
403475
# Not actually a Protocol at runtime; see
404476
# https://github.com/python/typeshed/issues/10224 for why we're defining it this way
405477
def __buffer__(self, __flags: int) -> memoryview: ...
478+
479+
if sys.version_info >= (3, 13):
480+
from typing import get_protocol_members as get_protocol_members, is_protocol as is_protocol
481+
else:
482+
def is_protocol(__tp: type) -> bool: ...
483+
def get_protocol_members(__tp: type) -> frozenset[str]: ...

tests/stubtest_allowlists/py310.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ _collections_abc.MutableMapping.setdefault
118118

119119
# typing.IO uses positional-or-keyword arguments, but in the stubs we prefer
120120
# to mark these as positional-only for compatibility with existing sub-classes.
121-
typing.BinaryIO.write
122-
typing.IO.read
123-
typing.IO.readline
124-
typing.IO.readlines
125-
typing.IO.seek
126-
typing.IO.truncate
127-
typing.IO.write
128-
typing.IO.writelines
121+
typing(_extensions)?\.BinaryIO\.write
122+
typing(_extensions)?\.IO\.read
123+
typing(_extensions)?\.IO\.readline
124+
typing(_extensions)?\.IO\.readlines
125+
typing(_extensions)?\.IO\.seek
126+
typing(_extensions)?\.IO\.truncate
127+
typing(_extensions)?\.IO\.write
128+
typing(_extensions)?\.IO\.writelines
129129

130130
# positional-only complaints caused by differences between typing aliases and the "real" classes in the stdlib
131131
_collections_abc.Coroutine.send

tests/stubtest_allowlists/py311.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ _collections_abc.MutableMapping.setdefault
5050

5151
# typing.IO uses positional-or-keyword arguments, but in the stubs we prefer
5252
# to mark these as positional-only for compatibility with existing sub-classes.
53-
typing.BinaryIO.write
54-
typing.IO.read
55-
typing.IO.readline
56-
typing.IO.readlines
57-
typing.IO.seek
58-
typing.IO.truncate
59-
typing.IO.write
60-
typing.IO.writelines
53+
typing(_extensions)?\.BinaryIO\.write
54+
typing(_extensions)?\.IO\.read
55+
typing(_extensions)?\.IO\.readline
56+
typing(_extensions)?\.IO\.readlines
57+
typing(_extensions)?\.IO\.seek
58+
typing(_extensions)?\.IO\.truncate
59+
typing(_extensions)?\.IO\.write
60+
typing(_extensions)?\.IO\.writelines
6161

6262
# positional-only complaints caused by differences between typing aliases and the "real" classes in the stdlib
6363
_collections_abc.Coroutine.send

tests/stubtest_allowlists/py312.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ _collections_abc.MutableMapping.setdefault
163163

164164
# typing.IO uses positional-or-keyword arguments, but in the stubs we prefer
165165
# to mark these as positional-only for compatibility with existing sub-classes.
166-
typing.BinaryIO.write
167-
typing.IO.read
168-
typing.IO.readline
169-
typing.IO.readlines
170-
typing.IO.seek
171-
typing.IO.truncate
172-
typing.IO.write
173-
typing.IO.writelines
166+
typing(_extensions)?\.BinaryIO\.write
167+
typing(_extensions)?\.IO\.read
168+
typing(_extensions)?\.IO\.readline
169+
typing(_extensions)?\.IO\.readlines
170+
typing(_extensions)?\.IO\.seek
171+
typing(_extensions)?\.IO\.truncate
172+
typing(_extensions)?\.IO\.write
173+
typing(_extensions)?\.IO\.writelines
174174

175175
# positional-only complaints caused by differences between typing aliases and the "real" classes in the stdlib
176176
_collections_abc.Coroutine.send

tests/stubtest_allowlists/py3_common.txt

+40-40
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ tkinter.tix.[A-Z_]+
9999
tkinter.tix.TclVersion
100100
tkinter.tix.TkVersion
101101
traceback.TracebackException.from_exception # explicitly expanding arguments going into TracebackException __init__
102-
typing.IO.__next__ # Added because IO streams are iterable. See https://github.com/python/typeshed/commit/97bc450acd60c1bcdafef3ce8fbe3b95a9c0cac3
102+
typing(_extensions)?\.IO\.__next__ # Added because IO streams are iterable. See https://github.com/python/typeshed/commit/97bc450acd60c1bcdafef3ce8fbe3b95a9c0cac3
103103
typing.type_check_only # typing decorator that is not available at runtime
104104
unittest.mock.patch # It's a complicated overload and I haven't been able to figure out why stubtest doesn't like it
105105
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
@@ -383,52 +383,52 @@ tempfile._TemporaryFileWrapper.[\w_]+ # Dynamically specified by __getattr__, a
383383
typing_extensions\._SpecialForm.*
384384
typing_extensions\.TypeVar.*
385385
typing_extensions\.ParamSpec.*
386-
typing\.Generic
386+
typing(_extensions)?\.Generic
387387
typing\.Protocol
388+
typing_extensions\._TypedDict\..*
388389

389390
# Special primitives
390391
typing_extensions\.Annotated
391392
typing_extensions\.NamedTuple
392393
typing_extensions\.LiteralString
393394
typing_extensions\.Coroutine
394395
typing_extensions\.Awaitable
395-
typing_extensions\.AsyncIterator
396-
typing_extensions\.AsyncIterable
397-
typing_extensions\.AsyncGenerator
398-
typing\.ValuesView
399-
typing\.Sized
400-
typing\.Sequence
401-
typing\.Reversible
402-
typing\.Pattern
403-
typing\.MutableSet
404-
typing\.MutableSequence
405-
typing\.MutableMapping
406-
typing\.Match
407-
typing\.MappingView
408-
typing\.Mapping
409-
typing\.KeysView
410-
typing\.Iterator
411-
typing\.Iterable
412-
typing\.ItemsView
413-
typing\.Hashable
414-
typing\.Generator
415-
typing\.Coroutine
416-
typing\.Collection
417-
typing\.Container
396+
typing(_extensions)?\.AsyncIterator
397+
typing(_extensions)?\.AsyncIterable
398+
typing(_extensions)?\.AsyncGenerator
399+
typing(_extensions)?\.ValuesView
400+
typing(_extensions)?\.Sized
401+
typing(_extensions)?\.Sequence
402+
typing(_extensions)?\.Reversible
403+
typing(_extensions)?\.Pattern
404+
typing(_extensions)?\.MutableSet
405+
typing(_extensions)?\.MutableSequence
406+
typing(_extensions)?\.MutableMapping
407+
typing(_extensions)?\.Match
408+
typing(_extensions)?\.MappingView
409+
typing(_extensions)?\.Mapping
410+
typing(_extensions)?\.KeysView
411+
typing(_extensions)?\.Iterator
412+
typing(_extensions)?\.Iterable
413+
typing(_extensions)?\.ItemsView
414+
typing(_extensions)?\.Hashable
415+
typing(_extensions)?\.Generator
416+
typing(_extensions)?\.Coroutine
417+
typing(_extensions)?\.Collection
418+
typing(_extensions)?\.Container
418419
typing\.ByteString
419-
typing\.AwaitableGenerator
420-
typing\.Awaitable
421-
typing\.AsyncIterator
422-
typing\.AsyncIterable
423-
typing\.AsyncGenerator
424-
typing\.AbstractSet
420+
typing(_extensions)?\.AwaitableGenerator
421+
typing(_extensions)?\.Awaitable
422+
typing(_extensions)?\.AbstractSet
425423

426424
typing_extensions.NewType.__mro_entries__ # just exists for an error message
427425

428426
# https://github.com/python/mypy/issues/15302
429427
typing_extensions.NewType.__call__
430428
typing_extensions\.deprecated
431429
typing_extensions\.override
430+
typing_extensions\.get_protocol_members
431+
typing_extensions\.is_protocol
432432

433433
# Typing-related weirdness
434434
_collections_abc.Callable
@@ -443,14 +443,14 @@ _collections_abc.ByteString
443443

444444
# These are abstract properties at runtime,
445445
# but marking them as such in the stub breaks half the the typed-Python ecosystem (see #8726)
446-
typing.IO.closed
447-
typing.IO.mode
448-
typing.IO.name
449-
typing.TextIO.buffer
450-
typing.TextIO.encoding
451-
typing.TextIO.errors
452-
typing.TextIO.line_buffering
453-
typing.TextIO.newlines
446+
typing(_extensions)?\.IO\.closed
447+
typing(_extensions)?\.IO\.mode
448+
typing(_extensions)?\.IO\.name
449+
typing(_extensions)?\.TextIO\.buffer
450+
typing(_extensions)?\.TextIO\.encoding
451+
typing(_extensions)?\.TextIO\.errors
452+
typing(_extensions)?\.TextIO\.line_buffering
453+
typing(_extensions)?\.TextIO\.newlines
454454

455455
types.MethodType.__closure__ # read-only but not actually a property; stubtest thinks it doesn't exist.
456456
types.MethodType.__defaults__ # read-only but not actually a property; stubtest thinks it doesn't exist.
@@ -599,7 +599,7 @@ mmap.mmap.__iter__
599599
mmap.mmap.__contains__
600600
xml.etree.ElementTree.Element.__iter__
601601
xml.etree.cElementTree.Element.__iter__
602-
typing.IO.__iter__ # See https://github.com/python/typeshed/commit/97bc450acd60c1bcdafef3ce8fbe3b95a9c0cac3
602+
typing(_extensions)?\.IO\.__iter__ # See https://github.com/python/typeshed/commit/97bc450acd60c1bcdafef3ce8fbe3b95a9c0cac3
603603

604604
# LC_MESSAGES is sometimes present in __all__, sometimes not,
605605
# so stubtest will sometimes complain about exported names being different at runtime to the exported names in the stub

0 commit comments

Comments
 (0)