There are two related, but different strands of conversation here:
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 and collections.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 and collections.abc.ByteString. I'm fine with going slow on the removal of typing.ByteString, since once it's a union in typeshed it's not causing much harm. But ideally we can remove collections.abc.ByteString in 3.14, since its isinstance behaviour is not what you want.
cc @JelleZijlstra
There are two related, but different strands of conversation here:
collections.abc.ByteStringis useless and confusing: Deprecate and schedule removal of collections.abc.ByteString and typing.ByteString #91896bytescan be used as a shorthand fortyping.ByteStringand includesmemoryviewandbytearrayhttps://peps.python.org/pep-0688/However, there is an additional issue!
collections.abc.ByteStringis not an accurate replacement fortyping.ByteString!collections.abc.ByteStringonly registersbytesandbytearray, whereastyping.ByteStringis documented as also representing a memoryview. This is an issue regardless of the above two related conversations.For this issue we could:
typing.ByteStringout from under the "Corresponding to collections in collections.abc" section to the "Other concrete types" sectioncollections.abc.ByteStringfrom typing.rsttyping.ByteStringas being deprecated, but change the reason. ByteString is not a generic type andcollections.abc.ByteStringis not a semantic replacement for it as above, so the current reason is wrong on two countstyping.ByteStringin typeshed as a simple Union, and not the Sequence[int] thing it is right now.typing.ByteStringas 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:
typing.ByteStringandcollections.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.ByteStringin 3.14, since its isinstance behaviour is not what you want.cc @JelleZijlstra