Skip to content

Commit cc0ce1e

Browse files
authored
Revert "Byestring removal for 3.14 (#12490)" (#14743)
1 parent 00790cb commit cc0ce1e

File tree

8 files changed

+12
-47
lines changed

8 files changed

+12
-47
lines changed

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ _collections_abc.AsyncGenerator.__anext__
181181
_collections_abc.AsyncGenerator.aclose
182182
_collections_abc.AsyncIterator.__anext__
183183

184+
# Pretend typing.ByteString is a Union, to better match its documented semantics.
185+
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
186+
# because it's not an ABC that makes any sense and was deprecated in 3.12
187+
_collections_abc\.ByteString
188+
typing\.ByteString
189+
184190
_collections_abc.Callable # Typing-related weirdness
185191
_collections_abc.Mapping.get # Adding None to the Union messed up mypy
186192
_collections_abc.Sequence.index # Supporting None in end is not mandatory

stdlib/@tests/stubtest_allowlists/py310.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,12 @@ tkinter.tix.TkVersion
155155
# <= 3.13
156156
# =======
157157

158-
# Pretend typing.ByteString is a Union, to better match its documented semantics.
159-
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
160-
# because it's not an ABC that makes any sense and was deprecated in 3.12
161-
_collections_abc.ByteString
162-
163158
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
164159

165160
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
166161

167162
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
168163

169-
typing\.ByteString
170-
171164
# Will always raise. Not included to avoid type checkers inferring that
172165
# TypeAliasType instances are callable.
173166
typing_extensions.TypeAliasType.__call__

stdlib/@tests/stubtest_allowlists/py311.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,12 @@ tkinter.tix.TkVersion
121121
# <= 3.13
122122
# =======
123123

124-
# Pretend typing.ByteString is a Union, to better match its documented semantics.
125-
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
126-
# because it's not an ABC that makes any sense and was deprecated in 3.12
127-
_collections_abc.ByteString
128-
129124
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
130125

131126
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
132127

133128
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
134129

135-
typing\.ByteString
136-
137130
# Will always raise. Not included to avoid type checkers inferring that
138131
# TypeAliasType instances are callable.
139132
typing_extensions.TypeAliasType.__call__

stdlib/@tests/stubtest_allowlists/py312.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,12 @@ tkinter.tix.TkVersion
120120
# <= 3.13
121121
# =======
122122

123-
# Pretend typing.ByteString is a Union, to better match its documented semantics.
124-
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
125-
# because it's not an ABC that makes any sense and was deprecated in 3.12
126-
_collections_abc.ByteString
127-
128123
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
129124

130125
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
131126

132127
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
133128

134-
typing\.ByteString
135-
136129
# Will always raise. Not included to avoid type checkers inferring that
137130
# TypeAliasType instances are callable.
138131
typing_extensions.TypeAliasType.__call__

stdlib/@tests/stubtest_allowlists/py313.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,12 @@ typing(_extensions)?\.IO\.writelines
8181
# <= 3.13
8282
# =======
8383

84-
# Pretend typing.ByteString is a Union, to better match its documented semantics.
85-
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
86-
# because it's not an ABC that makes any sense and was deprecated in 3.12
87-
_collections_abc.ByteString
88-
8984
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
9085

9186
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
9287

9388
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
9489

95-
typing\.ByteString
96-
9790
# Will always raise. Not included to avoid type checkers inferring that
9891
# TypeAliasType instances are callable.
9992
typing_extensions.TypeAliasType.__call__

stdlib/@tests/stubtest_allowlists/py39.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ collections.AsyncGenerator.__anext__ # async at runtime, deliberately not in th
1818
collections.AsyncGenerator.aclose # async at runtime, deliberately not in the stub, see #7491
1919
collections.AsyncGenerator.asend # async at runtime, deliberately not in the stub, see #7491. Pos-only differences also.
2020
collections.AsyncIterator.__anext__ # async at runtime, deliberately not in the stub, see #7491
21-
collections.ByteString # see comments in py3_common.txt
21+
collections.ByteString # see comments in common.txt
2222
collections.Callable
2323
collections.Mapping.get # Adding None to the Union messed up mypy
2424
collections.Sequence.index # Supporting None in end is not mandatory
@@ -104,19 +104,12 @@ tkinter.tix.TkVersion
104104
# <= 3.13
105105
# =======
106106

107-
# Pretend typing.ByteString is a Union, to better match its documented semantics.
108-
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
109-
# because it's not an ABC that makes any sense and was deprecated in 3.12
110-
_collections_abc.ByteString
111-
112107
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
113108

114109
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
115110

116111
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
117112

118-
typing\.ByteString
119-
120113
# Will always raise. Not included to avoid type checkers inferring that
121114
# TypeAliasType instances are callable.
122115
typing_extensions.TypeAliasType.__call__

stdlib/_collections_abc.pyi

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import sys
22
from abc import abstractmethod
33
from types import MappingProxyType
4-
from typing import ( # noqa: Y022,Y038,UP035
4+
from typing import ( # noqa: Y022,Y038,UP035,Y057
55
AbstractSet as Set,
66
AsyncGenerator as AsyncGenerator,
77
AsyncIterable as AsyncIterable,
88
AsyncIterator as AsyncIterator,
99
Awaitable as Awaitable,
10+
ByteString as ByteString,
1011
Callable as Callable,
1112
ClassVar,
1213
Collection as Collection,
@@ -59,12 +60,8 @@ __all__ = [
5960
"ValuesView",
6061
"Sequence",
6162
"MutableSequence",
63+
"ByteString",
6264
]
63-
if sys.version_info < (3, 14):
64-
from typing import ByteString as ByteString # noqa: Y057,UP035
65-
66-
__all__ += ["ByteString"]
67-
6865
if sys.version_info >= (3, 12):
6966
__all__ += ["Buffer"]
7067

stdlib/typing.pyi

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ __all__ = [
4141
"AsyncIterator",
4242
"Awaitable",
4343
"BinaryIO",
44+
"ByteString",
4445
"Callable",
4546
"ChainMap",
4647
"ClassVar",
@@ -109,9 +110,6 @@ __all__ = [
109110
"runtime_checkable",
110111
]
111112

112-
if sys.version_info < (3, 14):
113-
__all__ += ["ByteString"]
114-
115113
if sys.version_info >= (3, 14):
116114
__all__ += ["evaluate_forward_ref"]
117115

@@ -923,8 +921,7 @@ class TextIO(IO[str]):
923921
@abstractmethod
924922
def __enter__(self) -> TextIO: ...
925923

926-
if sys.version_info < (3, 14):
927-
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview
924+
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview
928925

929926
# Functions
930927

0 commit comments

Comments
 (0)