Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions stdlib/@tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
7 changes: 0 additions & 7 deletions stdlib/@tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
7 changes: 0 additions & 7 deletions stdlib/@tests/stubtest_allowlists/py312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
7 changes: 0 additions & 7 deletions stdlib/@tests/stubtest_allowlists/py313.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
9 changes: 1 addition & 8 deletions stdlib/@tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__
Expand Down
9 changes: 3 additions & 6 deletions stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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"]

Expand Down
7 changes: 2 additions & 5 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ __all__ = [
"AsyncIterator",
"Awaitable",
"BinaryIO",
"ByteString",
"Callable",
"ChainMap",
"ClassVar",
Expand Down Expand Up @@ -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"]

Expand Down Expand Up @@ -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

Expand Down
Loading