Repository navigation
Attempt to clarify the ByteString situation - #9783
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! |
| def __enter__(self) -> TextIO: ... | ||
|
|
||
| class ByteString(Sequence[int], metaclass=ABCMeta): ... | ||
| ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview |
There was a problem hiding this comment.
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