Skip to content

Commit 688913b

Browse files
committed
Revert Remove redundant inheritances from Iterator in builtins
1 parent 2b0f220 commit 688913b

File tree

7 files changed

+34
-34
lines changed

7 files changed

+34
-34
lines changed

mypy/typeshed/stdlib/_asyncio.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from asyncio.events import AbstractEventLoop
3-
from collections.abc import Awaitable, Callable, Coroutine, Generator
3+
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable
44
from contextvars import Context
55
from types import FrameType, GenericAlias
66
from typing import Any, Literal, TextIO, TypeVar
@@ -11,7 +11,7 @@ _T_co = TypeVar("_T_co", covariant=True)
1111
_TaskYieldType: TypeAlias = Future[object] | None
1212

1313
@disjoint_base
14-
class Future(Awaitable[_T]):
14+
class Future(Awaitable[_T], Iterable[_T]):
1515
_state: str
1616
@property
1717
def _exception(self) -> BaseException | None: ...

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ class frozenset(AbstractSet[_T_co]):
12101210
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
12111211

12121212
@disjoint_base
1213-
class enumerate(Generic[_T]):
1213+
class enumerate(Iterator[tuple[int, _T]]):
12141214
def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ...
12151215
def __iter__(self) -> Self: ...
12161216
def __next__(self) -> tuple[int, _T]: ...
@@ -1404,7 +1404,7 @@ else:
14041404
exit: _sitebuiltins.Quitter
14051405

14061406
@disjoint_base
1407-
class filter(Generic[_T]):
1407+
class filter(Iterator[_T]):
14081408
@overload
14091409
def __new__(cls, function: None, iterable: Iterable[_T | None], /) -> Self: ...
14101410
@overload
@@ -1468,7 +1468,7 @@ license: _sitebuiltins._Printer
14681468

14691469
def locals() -> dict[str, Any]: ...
14701470
@disjoint_base
1471-
class map(Generic[_S]):
1471+
class map(Iterator[_S]):
14721472
# 3.14 adds `strict` argument.
14731473
if sys.version_info >= (3, 14):
14741474
@overload
@@ -1775,7 +1775,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex
17751775
quit: _sitebuiltins.Quitter
17761776

17771777
@disjoint_base
1778-
class reversed(Generic[_T]):
1778+
class reversed(Iterator[_T]):
17791779
@overload
17801780
def __new__(cls, sequence: Reversible[_T], /) -> Iterator[_T]: ... # type: ignore[misc]
17811781
@overload
@@ -1839,7 +1839,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
18391839
@overload
18401840
def vars(object: Any = ..., /) -> dict[str, Any]: ...
18411841
@disjoint_base
1842-
class zip(Generic[_T_co]):
1842+
class zip(Iterator[_T_co]):
18431843
if sys.version_info >= (3, 10):
18441844
@overload
18451845
def __new__(cls, *, strict: bool = False) -> zip[Any]: ...

mypy/typeshed/stdlib/csv.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ else:
2525
from _csv import _reader as Reader, _writer as Writer
2626

2727
from _typeshed import SupportsWrite
28-
from collections.abc import Collection, Iterable, Mapping, Sequence
28+
from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence
2929
from types import GenericAlias
3030
from typing import Any, Generic, Literal, TypeVar, overload
3131
from typing_extensions import Self
@@ -73,7 +73,7 @@ class excel(Dialect): ...
7373
class excel_tab(excel): ...
7474
class unix_dialect(Dialect): ...
7575

76-
class DictReader(Generic[_T]):
76+
class DictReader(Iterator[dict[_T | Any, str | Any]], Generic[_T]):
7777
fieldnames: Sequence[_T] | None
7878
restkey: _T | None
7979
restval: str | Any | None

mypy/typeshed/stdlib/fileinput.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import sys
22
from _typeshed import AnyStr_co, StrOrBytesPath
3-
from collections.abc import Callable, Iterable
3+
from collections.abc import Callable, Iterable, Iterator
44
from types import GenericAlias, TracebackType
5-
from typing import IO, Any, AnyStr, Generic, Literal, Protocol, overload, type_check_only
5+
from typing import IO, Any, AnyStr, Literal, Protocol, overload, type_check_only
66
from typing_extensions import Self, TypeAlias
77

88
__all__ = [
@@ -105,7 +105,7 @@ def fileno() -> int: ...
105105
def isfirstline() -> bool: ...
106106
def isstdin() -> bool: ...
107107

108-
class FileInput(Generic[AnyStr]):
108+
class FileInput(Iterator[AnyStr]):
109109
if sys.version_info >= (3, 10):
110110
# encoding and errors are added
111111
@overload

mypy/typeshed/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
# Technically count can take anything that implements a number protocol and has an add method
2929
# but we can't enforce the add method
3030
@disjoint_base
31-
class count(Generic[_N]):
31+
class count(Iterator[_N]):
3232
@overload
3333
def __new__(cls) -> count[int]: ...
3434
@overload
@@ -39,13 +39,13 @@ class count(Generic[_N]):
3939
def __iter__(self) -> Self: ...
4040

4141
@disjoint_base
42-
class cycle(Generic[_T]):
42+
class cycle(Iterator[_T]):
4343
def __new__(cls, iterable: Iterable[_T], /) -> Self: ...
4444
def __next__(self) -> _T: ...
4545
def __iter__(self) -> Self: ...
4646

4747
@disjoint_base
48-
class repeat(Generic[_T]):
48+
class repeat(Iterator[_T]):
4949
@overload
5050
def __new__(cls, object: _T) -> Self: ...
5151
@overload
@@ -55,7 +55,7 @@ class repeat(Generic[_T]):
5555
def __length_hint__(self) -> int: ...
5656

5757
@disjoint_base
58-
class accumulate(Generic[_T]):
58+
class accumulate(Iterator[_T]):
5959
@overload
6060
def __new__(cls, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> Self: ...
6161
@overload
@@ -64,7 +64,7 @@ class accumulate(Generic[_T]):
6464
def __next__(self) -> _T: ...
6565

6666
@disjoint_base
67-
class chain(Generic[_T]):
67+
class chain(Iterator[_T]):
6868
def __new__(cls, *iterables: Iterable[_T]) -> Self: ...
6969
def __next__(self) -> _T: ...
7070
def __iter__(self) -> Self: ...
@@ -74,25 +74,25 @@ class chain(Generic[_T]):
7474
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
7575

7676
@disjoint_base
77-
class compress(Generic[_T]):
77+
class compress(Iterator[_T]):
7878
def __new__(cls, data: Iterable[_T], selectors: Iterable[Any]) -> Self: ...
7979
def __iter__(self) -> Self: ...
8080
def __next__(self) -> _T: ...
8181

8282
@disjoint_base
83-
class dropwhile(Generic[_T]):
83+
class dropwhile(Iterator[_T]):
8484
def __new__(cls, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> Self: ...
8585
def __iter__(self) -> Self: ...
8686
def __next__(self) -> _T: ...
8787

8888
@disjoint_base
89-
class filterfalse(Generic[_T]):
89+
class filterfalse(Iterator[_T]):
9090
def __new__(cls, function: _Predicate[_T] | None, iterable: Iterable[_T], /) -> Self: ...
9191
def __iter__(self) -> Self: ...
9292
def __next__(self) -> _T: ...
9393

9494
@disjoint_base
95-
class groupby(Generic[_T_co, _S_co]):
95+
class groupby(Iterator[tuple[_T_co, Iterator[_S_co]]], Generic[_T_co, _S_co]):
9696
@overload
9797
def __new__(cls, iterable: Iterable[_T1], key: None = None) -> groupby[_T1, _T1]: ...
9898
@overload
@@ -101,7 +101,7 @@ class groupby(Generic[_T_co, _S_co]):
101101
def __next__(self) -> tuple[_T_co, Iterator[_S_co]]: ...
102102

103103
@disjoint_base
104-
class islice(Generic[_T]):
104+
class islice(Iterator[_T]):
105105
@overload
106106
def __new__(cls, iterable: Iterable[_T], stop: int | None, /) -> Self: ...
107107
@overload
@@ -110,20 +110,20 @@ class islice(Generic[_T]):
110110
def __next__(self) -> _T: ...
111111

112112
@disjoint_base
113-
class starmap(Generic[_T_co]):
113+
class starmap(Iterator[_T_co]):
114114
def __new__(cls, function: Callable[..., _T], iterable: Iterable[Iterable[Any]], /) -> starmap[_T]: ...
115115
def __iter__(self) -> Self: ...
116116
def __next__(self) -> _T_co: ...
117117

118118
@disjoint_base
119-
class takewhile(Generic[_T]):
119+
class takewhile(Iterator[_T]):
120120
def __new__(cls, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> Self: ...
121121
def __iter__(self) -> Self: ...
122122
def __next__(self) -> _T: ...
123123

124124
def tee(iterable: Iterable[_T], n: int = 2, /) -> tuple[Iterator[_T], ...]: ...
125125
@disjoint_base
126-
class zip_longest(Generic[_T_co]):
126+
class zip_longest(Iterator[_T_co]):
127127
# one iterable (fillvalue doesn't matter)
128128
@overload
129129
def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = ...) -> zip_longest[tuple[_T1]]: ...
@@ -202,7 +202,7 @@ class zip_longest(Generic[_T_co]):
202202
def __next__(self) -> _T_co: ...
203203

204204
@disjoint_base
205-
class product(Generic[_T_co]):
205+
class product(Iterator[_T_co]):
206206
@overload
207207
def __new__(cls, iter1: Iterable[_T1], /) -> product[tuple[_T1]]: ...
208208
@overload
@@ -288,7 +288,7 @@ class product(Generic[_T_co]):
288288
def __next__(self) -> _T_co: ...
289289

290290
@disjoint_base
291-
class permutations(Generic[_T_co]):
291+
class permutations(Iterator[_T_co]):
292292
@overload
293293
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> permutations[tuple[_T, _T]]: ...
294294
@overload
@@ -303,7 +303,7 @@ class permutations(Generic[_T_co]):
303303
def __next__(self) -> _T_co: ...
304304

305305
@disjoint_base
306-
class combinations(Generic[_T_co]):
306+
class combinations(Iterator[_T_co]):
307307
@overload
308308
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations[tuple[_T, _T]]: ...
309309
@overload
@@ -318,7 +318,7 @@ class combinations(Generic[_T_co]):
318318
def __next__(self) -> _T_co: ...
319319

320320
@disjoint_base
321-
class combinations_with_replacement(Generic[_T_co]):
321+
class combinations_with_replacement(Iterator[_T_co]):
322322
@overload
323323
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations_with_replacement[tuple[_T, _T]]: ...
324324
@overload
@@ -334,14 +334,14 @@ class combinations_with_replacement(Generic[_T_co]):
334334

335335
if sys.version_info >= (3, 10):
336336
@disjoint_base
337-
class pairwise(Generic[_T_co]):
337+
class pairwise(Iterator[_T_co]):
338338
def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ...
339339
def __iter__(self) -> Self: ...
340340
def __next__(self) -> _T_co: ...
341341

342342
if sys.version_info >= (3, 12):
343343
@disjoint_base
344-
class batched(Generic[_T_co]):
344+
class batched(Iterator[tuple[_T_co, ...]], Generic[_T_co]):
345345
if sys.version_info >= (3, 13):
346346
def __new__(cls, iterable: Iterable[_T_co], n: int, *, strict: bool = False) -> Self: ...
347347
else:

mypy/typeshed/stdlib/multiprocessing/pool.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import Callable, Iterable, Mapping
1+
from collections.abc import Callable, Iterable, Iterator, Mapping
22
from multiprocessing.context import DefaultContext, Process
33
from types import GenericAlias, TracebackType
44
from typing import Any, Final, Generic, TypeVar
@@ -32,7 +32,7 @@ class MapResult(ApplyResult[list[_T]]):
3232
error_callback: Callable[[BaseException], object] | None,
3333
) -> None: ...
3434

35-
class IMapIterator(Generic[_T]):
35+
class IMapIterator(Iterator[_T]):
3636
def __init__(self, pool: Pool) -> None: ...
3737
def __iter__(self) -> Self: ...
3838
def next(self, timeout: float | None = None) -> _T: ...

mypy/typeshed/stdlib/sqlite3/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ class Connection:
407407
) -> Literal[False]: ...
408408

409409
@disjoint_base
410-
class Cursor:
410+
class Cursor(Iterator[Any]):
411411
arraysize: int
412412
@property
413413
def connection(self) -> Connection: ...

0 commit comments

Comments
 (0)