diff --git a/stdlib/@tests/test_cases/builtins/check_memoryview.py b/stdlib/@tests/test_cases/builtins/check_memoryview.py index 9bcec4e5fb7f..1ece6e6b850b 100644 --- a/stdlib/@tests/test_cases/builtins/check_memoryview.py +++ b/stdlib/@tests/test_cases/builtins/check_memoryview.py @@ -1,6 +1,7 @@ from __future__ import annotations import array +import sys from typing_extensions import assert_type # Casting to bytes. @@ -57,5 +58,9 @@ mv = memoryview(b"abc") mv.cast("abc") # type: ignore -mv.index(42) # type: ignore -mv.count(42) # type: ignore +if sys.version_info >= (3, 14): + mv.index(42) + mv.count(42) +else: + mv.index(42) # type: ignore + mv.count(42) # type: ignore diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 38be452e8d49..fd095abcfcc8 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -944,11 +944,15 @@ class memoryview(Sequence[_I]): def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = 1) -> str: ... def __buffer__(self, flags: int, /) -> memoryview: ... def __release_buffer__(self, buffer: memoryview, /) -> None: ... + if sys.version_info >= (3, 14): + def index(self, value: object, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ... + def count(self, value: object, /) -> int: ... + else: + # 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] - # 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] if sys.version_info >= (3, 14): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...