-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Attempt to clarify the ByteString situation #9783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
See python/cpython#102092 This makes the behaviour of typing.ByteString better match its documentation. I also remove collections.abc.ByteString. There is no legitimate use case for it. Let me know if you think there's a case where it would help users to have this around.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
+1 at least for removing the subclass dependency to match runtime. (Even if the abc is registered at runtime.) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
For the record, I only clicked "approve" once; not sure how that happened! |
@@ -715,7 +715,7 @@ class TextIO(IO[str]): | |||
@abstractmethod | |||
def __enter__(self) -> TextIO: ... | |||
|
|||
class ByteString(Sequence[int], metaclass=ABCMeta): ... | |||
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this in person a bit. "bytes | bytearray | memoryview" matches the documented semantics of this symbol (https://docs.python.org/3.11/library/typing.html#typing.ByteString), but the previous stubs here in typeshed didn't include memoryview
, which is not a Sequence. It's a mess either way and that's why we deprecated this thing, but we may have to adjust this definition if people complain about it.
This still marked as draft, @hauntsaninja shall we land it? |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
See python/cpython#102092