Skip to content

Commit

Permalink
memoryview: re-add inheritance from Sequence, set index and count…
Browse files Browse the repository at this point in the history
… to None (#12800)

This reverts commit f625e92.
  • Loading branch information
JelleZijlstra authored Oct 16, 2024
1 parent 6feca18 commit 2370b8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions stdlib/@tests/test_cases/builtins/check_memoryview.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@
# An invalid literal should raise an error.
mv = memoryview(b"abc")
mv.cast("abc") # type: ignore

mv.index(42) # type: ignore
mv.count(42) # type: ignore
7 changes: 6 additions & 1 deletion stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ _IntegerFormats: TypeAlias = Literal[
]

@final
class memoryview(Generic[_I]):
class memoryview(Sequence[_I]):
@property
def format(self) -> str: ...
@property
Expand Down Expand Up @@ -897,6 +897,11 @@ class memoryview(Generic[_I]):
def __buffer__(self, flags: int, /) -> memoryview: ...
def __release_buffer__(self, buffer: memoryview, /) -> None: ...

# These are inherited from the Sequence ABC, but don't actually exist on memoryview.
# See https://github.com/python/cpython/issues/125420
index: ClassVar[None] # type: ignore[assignment]
count: ClassVar[None] # type: ignore[assignment]

@final
class bool(int):
def __new__(cls, o: object = ..., /) -> Self: ...
Expand Down

0 comments on commit 2370b8b

Please sign in to comment.