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
+2 -2
View File
@@ -123,14 +123,14 @@ class Element(Generic[_Tag]):
@overload
def __getitem__(self, key: SupportsIndex, /) -> Element: ...
@overload
def __getitem__(self, key: slice, /) -> list[Element]: ...
def __getitem__(self, key: slice[SupportsIndex | None], /) -> list[Element]: ...
def __len__(self) -> int: ...
# Doesn't actually exist at runtime, but instance of the class are indeed iterable due to __getitem__.
def __iter__(self) -> Iterator[Element]: ...
@overload
def __setitem__(self, key: SupportsIndex, value: Element[Any], /) -> None: ...
@overload
def __setitem__(self, key: slice, value: Iterable[Element[Any]], /) -> None: ...
def __setitem__(self, key: slice[SupportsIndex | None], value: Iterable[Element[Any]], /) -> None: ...
# Doesn't really exist in earlier versions, where __len__ is called implicitly instead
@deprecated("Testing an element's truth value is deprecated.")