From 8431e6c7c330bbca1ddd67171133c8de4b636c64 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 26 Nov 2021 19:50:49 +0000 Subject: [PATCH] Add missing `__class_getitem__` method to `itertools.chain` (#6389) --- stdlib/itertools.pyi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 9d666d681..1ff7ffc18 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -17,6 +17,9 @@ from typing import ( ) from typing_extensions import Literal, SupportsIndex +if sys.version_info >= (3, 9): + from types import GenericAlias + _T = TypeVar("_T") _S = TypeVar("_S") _N = TypeVar("_N", int, float, SupportsFloat, SupportsInt, SupportsIndex, SupportsComplex) @@ -67,6 +70,8 @@ class chain(Iterator[_T], Generic[_T]): @classmethod # We use Type and not Type[_S] to not lose the type inference from __iterable def from_iterable(cls: Type[Any], __iterable: Iterable[Iterable[_S]]) -> Iterator[_S]: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, __item: Any) -> GenericAlias: ... class compress(Iterator[_T], Generic[_T]): def __init__(self, data: Iterable[_T], selectors: Iterable[Any]) -> None: ...