mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-19 02:15:58 +08:00
Attempt to clarify the ByteString situation (#9783)
See https://github.com/python/cpython/issues/102092 This makes the behaviour of typing.ByteString better match its documentation.
This commit is contained in:
@@ -36,7 +36,6 @@ from typing import ( # noqa: Y022
|
||||
IO,
|
||||
Any,
|
||||
BinaryIO,
|
||||
ByteString,
|
||||
ClassVar,
|
||||
Generic,
|
||||
Mapping,
|
||||
@@ -592,7 +591,7 @@ class str(Sequence[str]):
|
||||
def __rmul__(self, __value: SupportsIndex) -> str: ... # type: ignore[misc]
|
||||
def __getnewargs__(self) -> tuple[str]: ...
|
||||
|
||||
class bytes(ByteString):
|
||||
class bytes(Sequence[int]):
|
||||
@overload
|
||||
def __new__(cls, __o: Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer) -> Self: ...
|
||||
@overload
|
||||
@@ -697,7 +696,7 @@ class bytes(ByteString):
|
||||
|
||||
def __buffer__(self, __flags: int) -> memoryview: ...
|
||||
|
||||
class bytearray(MutableSequence[int], ByteString):
|
||||
class bytearray(MutableSequence[int]):
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
@overload
|
||||
|
||||
@@ -771,7 +771,7 @@ class TextIO(IO[str]):
|
||||
@abstractmethod
|
||||
def __enter__(self) -> TextIO: ...
|
||||
|
||||
class ByteString(Sequence[int], metaclass=ABCMeta): ...
|
||||
ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview
|
||||
|
||||
# Functions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user