Skip to content

Commit 2370b8b

Browse files
memoryview: re-add inheritance from Sequence, set index and count to None (#12800)
This reverts commit f625e92.
1 parent 6feca18 commit 2370b8b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

stdlib/@tests/test_cases/builtins/check_memoryview.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@
5656
# An invalid literal should raise an error.
5757
mv = memoryview(b"abc")
5858
mv.cast("abc") # type: ignore
59+
60+
mv.index(42) # type: ignore
61+
mv.count(42) # type: ignore

stdlib/builtins.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ _IntegerFormats: TypeAlias = Literal[
834834
]
835835

836836
@final
837-
class memoryview(Generic[_I]):
837+
class memoryview(Sequence[_I]):
838838
@property
839839
def format(self) -> str: ...
840840
@property
@@ -897,6 +897,11 @@ class memoryview(Generic[_I]):
897897
def __buffer__(self, flags: int, /) -> memoryview: ...
898898
def __release_buffer__(self, buffer: memoryview, /) -> None: ...
899899

900+
# These are inherited from the Sequence ABC, but don't actually exist on memoryview.
901+
# See https://github.com/python/cpython/issues/125420
902+
index: ClassVar[None] # type: ignore[assignment]
903+
count: ClassVar[None] # type: ignore[assignment]
904+
900905
@final
901906
class bool(int):
902907
def __new__(cls, o: object = ..., /) -> Self: ...

0 commit comments

Comments
 (0)