Skip to content

Commit 281dd35

Browse files
authored
Remove redundant inheritances from Iterator in itertools (python#12816)
1 parent 8113832 commit 281dd35

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

stdlib/itertools.pyi

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ _Predicate: TypeAlias = Callable[[_T], object]
2828

2929
# Technically count can take anything that implements a number protocol and has an add method
3030
# but we can't enforce the add method
31-
class count(Iterator[_N]):
31+
class count(Generic[_N]):
3232
@overload
3333
def __new__(cls) -> count[int]: ...
3434
@overload
@@ -38,12 +38,12 @@ class count(Iterator[_N]):
3838
def __next__(self) -> _N: ...
3939
def __iter__(self) -> Self: ...
4040

41-
class cycle(Iterator[_T]):
41+
class cycle(Generic[_T]):
4242
def __init__(self, iterable: Iterable[_T], /) -> None: ...
4343
def __next__(self) -> _T: ...
4444
def __iter__(self) -> Self: ...
4545

46-
class repeat(Iterator[_T]):
46+
class repeat(Generic[_T]):
4747
@overload
4848
def __init__(self, object: _T) -> None: ...
4949
@overload
@@ -52,15 +52,15 @@ class repeat(Iterator[_T]):
5252
def __iter__(self) -> Self: ...
5353
def __length_hint__(self) -> int: ...
5454

55-
class accumulate(Iterator[_T]):
55+
class accumulate(Generic[_T]):
5656
@overload
5757
def __init__(self, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> None: ...
5858
@overload
5959
def __init__(self, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = ...) -> None: ...
6060
def __iter__(self) -> Self: ...
6161
def __next__(self) -> _T: ...
6262

63-
class chain(Iterator[_T]):
63+
class chain(Generic[_T]):
6464
def __init__(self, *iterables: Iterable[_T]) -> None: ...
6565
def __next__(self) -> _T: ...
6666
def __iter__(self) -> Self: ...
@@ -70,50 +70,50 @@ class chain(Iterator[_T]):
7070
if sys.version_info >= (3, 9):
7171
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
7272

73-
class compress(Iterator[_T]):
73+
class compress(Generic[_T]):
7474
def __init__(self, data: Iterable[_T], selectors: Iterable[Any]) -> None: ...
7575
def __iter__(self) -> Self: ...
7676
def __next__(self) -> _T: ...
7777

78-
class dropwhile(Iterator[_T]):
78+
class dropwhile(Generic[_T]):
7979
def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
8080
def __iter__(self) -> Self: ...
8181
def __next__(self) -> _T: ...
8282

83-
class filterfalse(Iterator[_T]):
83+
class filterfalse(Generic[_T]):
8484
def __init__(self, predicate: _Predicate[_T] | None, iterable: Iterable[_T], /) -> None: ...
8585
def __iter__(self) -> Self: ...
8686
def __next__(self) -> _T: ...
8787

88-
class groupby(Iterator[tuple[_T_co, Iterator[_S_co]]], Generic[_T_co, _S_co]):
88+
class groupby(Generic[_T_co, _S_co]):
8989
@overload
9090
def __new__(cls, iterable: Iterable[_T1], key: None = None) -> groupby[_T1, _T1]: ...
9191
@overload
9292
def __new__(cls, iterable: Iterable[_T1], key: Callable[[_T1], _T2]) -> groupby[_T2, _T1]: ...
9393
def __iter__(self) -> Self: ...
9494
def __next__(self) -> tuple[_T_co, Iterator[_S_co]]: ...
9595

96-
class islice(Iterator[_T]):
96+
class islice(Generic[_T]):
9797
@overload
9898
def __init__(self, iterable: Iterable[_T], stop: int | None, /) -> None: ...
9999
@overload
100100
def __init__(self, iterable: Iterable[_T], start: int | None, stop: int | None, step: int | None = ..., /) -> None: ...
101101
def __iter__(self) -> Self: ...
102102
def __next__(self) -> _T: ...
103103

104-
class starmap(Iterator[_T_co]):
104+
class starmap(Generic[_T_co]):
105105
def __new__(cls, function: Callable[..., _T], iterable: Iterable[Iterable[Any]], /) -> starmap[_T]: ...
106106
def __iter__(self) -> Self: ...
107107
def __next__(self) -> _T_co: ...
108108

109-
class takewhile(Iterator[_T]):
109+
class takewhile(Generic[_T]):
110110
def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
111111
def __iter__(self) -> Self: ...
112112
def __next__(self) -> _T: ...
113113

114114
def tee(iterable: Iterable[_T], n: int = 2, /) -> tuple[Iterator[_T], ...]: ...
115115

116-
class zip_longest(Iterator[_T_co]):
116+
class zip_longest(Generic[_T_co]):
117117
# one iterable (fillvalue doesn't matter)
118118
@overload
119119
def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = ...) -> zip_longest[tuple[_T1]]: ...
@@ -191,7 +191,7 @@ class zip_longest(Iterator[_T_co]):
191191
def __iter__(self) -> Self: ...
192192
def __next__(self) -> _T_co: ...
193193

194-
class product(Iterator[_T_co]):
194+
class product(Generic[_T_co]):
195195
@overload
196196
def __new__(cls, iter1: Iterable[_T1], /) -> product[tuple[_T1]]: ...
197197
@overload
@@ -276,7 +276,7 @@ class product(Iterator[_T_co]):
276276
def __iter__(self) -> Self: ...
277277
def __next__(self) -> _T_co: ...
278278

279-
class permutations(Iterator[_T_co]):
279+
class permutations(Generic[_T_co]):
280280
@overload
281281
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> permutations[tuple[_T, _T]]: ...
282282
@overload
@@ -290,7 +290,7 @@ class permutations(Iterator[_T_co]):
290290
def __iter__(self) -> Self: ...
291291
def __next__(self) -> _T_co: ...
292292

293-
class combinations(Iterator[_T_co]):
293+
class combinations(Generic[_T_co]):
294294
@overload
295295
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations[tuple[_T, _T]]: ...
296296
@overload
@@ -304,7 +304,7 @@ class combinations(Iterator[_T_co]):
304304
def __iter__(self) -> Self: ...
305305
def __next__(self) -> _T_co: ...
306306

307-
class combinations_with_replacement(Iterator[_T_co]):
307+
class combinations_with_replacement(Generic[_T_co]):
308308
@overload
309309
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations_with_replacement[tuple[_T, _T]]: ...
310310
@overload
@@ -319,13 +319,13 @@ class combinations_with_replacement(Iterator[_T_co]):
319319
def __next__(self) -> _T_co: ...
320320

321321
if sys.version_info >= (3, 10):
322-
class pairwise(Iterator[_T_co]):
322+
class pairwise(Generic[_T_co]):
323323
def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ...
324324
def __iter__(self) -> Self: ...
325325
def __next__(self) -> _T_co: ...
326326

327327
if sys.version_info >= (3, 12):
328-
class batched(Iterator[tuple[_T_co, ...]], Generic[_T_co]):
328+
class batched(Generic[_T_co]):
329329
if sys.version_info >= (3, 13):
330330
def __new__(cls, iterable: Iterable[_T_co], n: int, *, strict: bool = False) -> Self: ...
331331
else:

0 commit comments

Comments
 (0)