-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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 #91896- That
bytescan be used as a shorthand fortyping.ByteStringand includesmemoryviewandbytearrayhttps://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.ByteStringout from under the "Corresponding to collections in collections.abc" section to the "Other concrete types" section - Remove all mention of
collections.abc.ByteStringfrom typing.rst - Keep the mention of
typing.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 counts - Define
typing.ByteStringin typeshed as a simple Union, and not the Sequence[int] thing it is right now. - Define
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:
- We should also remove the note about the bytes shorthand from the docs
- We should deprecate both
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.
srittau
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error