Closed
Description
There are two related, but different strands of conversation here:
collections.abc.ByteString
is useless and confusing: Deprecate and schedule removal of collections.abc.ByteString and typing.ByteString #91896- That
bytes
can be used as a shorthand fortyping.ByteString
and includesmemoryview
andbytearray
https://peps.python.org/pep-0688/
However, there is an additional issue! collections.abc.ByteString
is not an accurate replacement for typing.ByteString
! collections.abc.ByteString
only registers bytes
and bytearray
, whereas typing.ByteString
is documented as also representing a memoryview. This is an issue regardless of the above two related conversations.
For this issue we could:
- Move the documentation of
typing.ByteString
out from under the "Corresponding to collections in collections.abc" section to the "Other concrete types" section - Remove all mention of
collections.abc.ByteString
from typing.rst - Keep the mention of
typing.ByteString
as being deprecated, but change the reason. ByteString is not a generic type andcollections.abc.ByteString
is not a semantic replacement for it as above, so the current reason is wrong on two counts - Define
typing.ByteString
in typeshed as a simple Union, and not the Sequence[int] thing it is right now. - Define
typing.ByteString
as a Union in typing.py instead of the generic alias it is now(?)
Here's how this relates to the other two strands of conversation:
- We should also remove the note about the bytes shorthand from the docs
- We should deprecate both
typing.ByteString
andcollections.abc.ByteString
. I'm fine with going slow on the removal oftyping.ByteString
, since once it's a union in typeshed it's not causing much harm. But ideally we can removecollections.abc.ByteString
in 3.14, since its isinstance behaviour is not what you want.