mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
memoryview type information inconsistent with runtime behavior (#2230)
memoryview type information inconsistent with documentation of typing module. `memoryview` should be a ByteString like the docs say. `memoryview.__init__` does not accept str, and instead of a union it should just accept ByteString. `memoryview.__iter__` returns an Iterator[int] not bytes.
This commit is contained in:
committed by
Jelle Zijlstra
parent
395ab5abd1
commit
451deba4ef
@@ -358,7 +358,7 @@ class bytes(ByteString):
|
||||
def isspace(self) -> bool: ...
|
||||
def istitle(self) -> bool: ...
|
||||
def isupper(self) -> bool: ...
|
||||
def join(self, iterable: Iterable[bytes]) -> bytes: ...
|
||||
def join(self, iterable: Iterable[Union[ByteString, memoryview]]) -> bytes: ...
|
||||
def ljust(self, width: int, fillchar: bytes = ...) -> bytes: ...
|
||||
def lower(self) -> bytes: ...
|
||||
def lstrip(self, chars: Optional[bytes] = ...) -> bytes: ...
|
||||
@@ -451,7 +451,7 @@ class bytearray(MutableSequence[int], ByteString):
|
||||
def isspace(self) -> bool: ...
|
||||
def istitle(self) -> bool: ...
|
||||
def isupper(self) -> bool: ...
|
||||
def join(self, iterable: Iterable[bytes]) -> bytearray: ...
|
||||
def join(self, iterable: Iterable[Union[ByteString, memoryview]]) -> bytearray: ...
|
||||
def ljust(self, width: int, fillchar: bytes = ...) -> bytearray: ...
|
||||
def lower(self) -> bytearray: ...
|
||||
def lstrip(self, chars: Optional[bytes] = ...) -> bytearray: ...
|
||||
@@ -514,7 +514,7 @@ class bytearray(MutableSequence[int], ByteString):
|
||||
def __gt__(self, x: bytes) -> bool: ...
|
||||
def __ge__(self, x: bytes) -> bool: ...
|
||||
|
||||
class memoryview(Sized, Container[bytes]):
|
||||
class memoryview(Sized, Container[int]):
|
||||
format = ... # type: str
|
||||
itemsize = ... # type: int
|
||||
shape = ... # type: Optional[Tuple[int, ...]]
|
||||
@@ -523,7 +523,7 @@ class memoryview(Sized, Container[bytes]):
|
||||
readonly = ... # type: bool
|
||||
ndim = ... # type: int
|
||||
|
||||
def __init__(self, obj: Union[str, bytes, bytearray, memoryview]) -> None: ...
|
||||
def __init__(self, obj: Union[bytes, bytearray, memoryview]) -> None: ...
|
||||
|
||||
@overload
|
||||
def __getitem__(self, i: int) -> int: ...
|
||||
@@ -531,7 +531,7 @@ class memoryview(Sized, Container[bytes]):
|
||||
def __getitem__(self, s: slice) -> memoryview: ...
|
||||
|
||||
def __contains__(self, x: object) -> bool: ...
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def __iter__(self) -> Iterator[int]: ...
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user