Specialize plain slice type hints (#13007)

This commit is contained in:
Randolf Scholz
2026-01-23 10:35:39 +01:00
committed by GitHub
parent 2ff920f291
commit 5c49b1fe49
15 changed files with 69 additions and 69 deletions
+4 -4
View File
@@ -6,7 +6,7 @@ from abc import abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p
from types import GenericAlias
from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, final, overload, type_check_only
from typing import Any, ClassVar, Final, Generic, Literal, SupportsIndex, TypeVar, final, overload, type_check_only
from typing_extensions import Self, TypeAlias
_T = TypeVar("_T")
@@ -134,7 +134,7 @@ class _Pointer(_PointerLike, _CData, Generic[_CT], metaclass=_PyCPointerType):
@overload
def __getitem__(self, key: int, /) -> Any: ...
@overload
def __getitem__(self, key: slice, /) -> list[Any]: ...
def __getitem__(self, key: slice[SupportsIndex | None], /) -> list[Any]: ...
def __setitem__(self, key: int, value: Any, /) -> None: ...
if sys.version_info < (3, 14):
@@ -342,11 +342,11 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
@overload
def __getitem__(self, key: int, /) -> Any: ...
@overload
def __getitem__(self, key: slice, /) -> list[Any]: ...
def __getitem__(self, key: slice[SupportsIndex | None], /) -> list[Any]: ...
@overload
def __setitem__(self, key: int, value: Any, /) -> None: ...
@overload
def __setitem__(self, key: slice, value: Iterable[Any], /) -> None: ...
def __setitem__(self, key: slice[SupportsIndex | None], value: Iterable[Any], /) -> None: ...
def __iter__(self) -> Iterator[Any]: ...
# Can't inherit from Sized because the metaclass conflict between
# Sized and _CData prevents using _CDataMeta.