diff --git a/stdlib/@tests/test_cases/builtins/check_memoryview.py b/stdlib/@tests/test_cases/builtins/check_memoryview.py index 108fc8395..9bcec4e5f 100644 --- a/stdlib/@tests/test_cases/builtins/check_memoryview.py +++ b/stdlib/@tests/test_cases/builtins/check_memoryview.py @@ -56,3 +56,6 @@ assert_type(float_mv[0:2], memoryview[float]) # 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 diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 63c53a5f6..8a4a9829c 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -834,7 +834,7 @@ _IntegerFormats: TypeAlias = Literal[ ] @final -class memoryview(Generic[_I]): +class memoryview(Sequence[_I]): @property def format(self) -> str: ... @property @@ -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: ...