Skip to content

Commit f1359a6

Browse files
authored
[stdlib] memoryview updates for version 3.14 (#15102)
1 parent d9f078f commit f1359a6

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import array
4+
import sys
45
from typing_extensions import assert_type
56

67
# Casting to bytes.
@@ -57,5 +58,9 @@
5758
mv = memoryview(b"abc")
5859
mv.cast("abc") # type: ignore
5960

60-
mv.index(42) # type: ignore
61-
mv.count(42) # type: ignore
61+
if sys.version_info >= (3, 14):
62+
mv.index(42)
63+
mv.count(42)
64+
else:
65+
mv.index(42) # type: ignore
66+
mv.count(42) # type: ignore

stdlib/builtins.pyi

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -954,11 +954,15 @@ class memoryview(Sequence[_I]):
954954
def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = 1) -> str: ...
955955
def __buffer__(self, flags: int, /) -> memoryview: ...
956956
def __release_buffer__(self, buffer: memoryview, /) -> None: ...
957+
if sys.version_info >= (3, 14):
958+
def index(self, value: object, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ...
959+
def count(self, value: object, /) -> int: ...
960+
else:
961+
# These are inherited from the Sequence ABC, but don't actually exist on memoryview.
962+
# See https://github.com/python/cpython/issues/125420
963+
index: ClassVar[None] # type: ignore[assignment]
964+
count: ClassVar[None] # type: ignore[assignment]
957965

958-
# These are inherited from the Sequence ABC, but don't actually exist on memoryview.
959-
# See https://github.com/python/cpython/issues/125420
960-
index: ClassVar[None] # type: ignore[assignment]
961-
count: ClassVar[None] # type: ignore[assignment]
962966
if sys.version_info >= (3, 14):
963967
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
964968

0 commit comments

Comments
 (0)