Skip to content

Revert "memoryview: remove inheritance from Sequence" #12800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading