Revert "Byestring removal for 3.14 (#12490)" (#14743)

This commit is contained in:
Alex Waygood
2025-09-19 08:09:22 +01:00
committed by GitHub
parent 00790cb021
commit cc0ce1e500
8 changed files with 12 additions and 47 deletions
@@ -181,6 +181,12 @@ _collections_abc.AsyncGenerator.__anext__
_collections_abc.AsyncGenerator.aclose
_collections_abc.AsyncIterator.__anext__
# Pretend typing.ByteString is a Union, to better match its documented semantics.
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc\.ByteString
typing\.ByteString
_collections_abc.Callable # Typing-related weirdness
_collections_abc.Mapping.get # Adding None to the Union messed up mypy
_collections_abc.Sequence.index # Supporting None in end is not mandatory
@@ -155,19 +155,12 @@ tkinter.tix.TkVersion
# <= 3.13
# =======
# Pretend typing.ByteString is a Union, to better match its documented semantics.
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
typing\.ByteString
# Will always raise. Not included to avoid type checkers inferring that
# TypeAliasType instances are callable.
typing_extensions.TypeAliasType.__call__
@@ -121,19 +121,12 @@ tkinter.tix.TkVersion
# <= 3.13
# =======
# Pretend typing.ByteString is a Union, to better match its documented semantics.
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
typing\.ByteString
# Will always raise. Not included to avoid type checkers inferring that
# TypeAliasType instances are callable.
typing_extensions.TypeAliasType.__call__
@@ -120,19 +120,12 @@ tkinter.tix.TkVersion
# <= 3.13
# =======
# Pretend typing.ByteString is a Union, to better match its documented semantics.
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
typing\.ByteString
# Will always raise. Not included to avoid type checkers inferring that
# TypeAliasType instances are callable.
typing_extensions.TypeAliasType.__call__
@@ -81,19 +81,12 @@ typing(_extensions)?\.IO\.writelines
# <= 3.13
# =======
# Pretend typing.ByteString is a Union, to better match its documented semantics.
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
typing\.ByteString
# Will always raise. Not included to avoid type checkers inferring that
# TypeAliasType instances are callable.
typing_extensions.TypeAliasType.__call__
+1 -8
View File
@@ -18,7 +18,7 @@ collections.AsyncGenerator.__anext__ # async at runtime, deliberately not in th
collections.AsyncGenerator.aclose # async at runtime, deliberately not in the stub, see #7491
collections.AsyncGenerator.asend # async at runtime, deliberately not in the stub, see #7491. Pos-only differences also.
collections.AsyncIterator.__anext__ # async at runtime, deliberately not in the stub, see #7491
collections.ByteString # see comments in py3_common.txt
collections.ByteString # see comments in common.txt
collections.Callable
collections.Mapping.get # Adding None to the Union messed up mypy
collections.Sequence.index # Supporting None in end is not mandatory
@@ -104,19 +104,12 @@ tkinter.tix.TkVersion
# <= 3.13
# =======
# Pretend typing.ByteString is a Union, to better match its documented semantics.
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
typing\.ByteString
# Will always raise. Not included to avoid type checkers inferring that
# TypeAliasType instances are callable.
typing_extensions.TypeAliasType.__call__
+3 -6
View File
@@ -1,12 +1,13 @@
import sys
from abc import abstractmethod
from types import MappingProxyType
from typing import ( # noqa: Y022,Y038,UP035
from typing import ( # noqa: Y022,Y038,UP035,Y057
AbstractSet as Set,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable,
ClassVar,
Collection as Collection,
@@ -59,12 +60,8 @@ __all__ = [
"ValuesView",
"Sequence",
"MutableSequence",
"ByteString",
]
if sys.version_info < (3, 14):
from typing import ByteString as ByteString # noqa: Y057,UP035
__all__ += ["ByteString"]
if sys.version_info >= (3, 12):
__all__ += ["Buffer"]
+2 -5
View File
@@ -41,6 +41,7 @@ __all__ = [
"AsyncIterator",
"Awaitable",
"BinaryIO",
"ByteString",
"Callable",
"ChainMap",
"ClassVar",
@@ -109,9 +110,6 @@ __all__ = [
"runtime_checkable",
]
if sys.version_info < (3, 14):
__all__ += ["ByteString"]
if sys.version_info >= (3, 14):
__all__ += ["evaluate_forward_ref"]
@@ -923,8 +921,7 @@ class TextIO(IO[str]):
@abstractmethod
def __enter__(self) -> TextIO: ...
if sys.version_info < (3, 14):
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview
# Functions