@@ -5,9 +5,36 @@ Subject: [PATCH] Revert Remove redundant inheritances from Iterator in
55 builtins
66
77---
8- mypy/typeshed/stdlib/builtins.pyi | 10 +++++-----
9- 1 file changed, 5 insertions(+), 5 deletions(-)
8+ mypy/typeshed/stdlib/_asyncio.pyi | 4 +-
9+ mypy/typeshed/stdlib/builtins.pyi | 10 ++---
10+ mypy/typeshed/stdlib/csv.pyi | 4 +-
11+ mypy/typeshed/stdlib/fileinput.pyi | 6 +--
12+ mypy/typeshed/stdlib/itertools.pyi | 38 +++++++++----------
13+ mypy/typeshed/stdlib/multiprocessing/pool.pyi | 4 +-
14+ mypy/typeshed/stdlib/sqlite3/__init__.pyi | 2 +-
15+ 7 files changed, 34 insertions(+), 34 deletions(-)
1016
17+ diff --git a/mypy/typeshed/stdlib/_asyncio.pyi b/mypy/typeshed/stdlib/_asyncio.pyi
18+ index a25902661..18920cd8a 100644
19+ --- a/mypy/typeshed/stdlib/_asyncio.pyi
20+ +++ b/mypy/typeshed/stdlib/_asyncio.pyi
21+ @@ -1,6 +1,6 @@
22+ import sys
23+ from asyncio.events import AbstractEventLoop
24+ - from collections.abc import Awaitable, Callable, Coroutine, Generator
25+ + from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable
26+ from contextvars import Context
27+ from types import FrameType
28+ from typing import Any, Literal, TextIO, TypeVar
29+ @@ -13,7 +13,7 @@ _T = TypeVar("_T")
30+ _T_co = TypeVar("_T_co", covariant=True)
31+ _TaskYieldType: TypeAlias = Future[object] | None
32+
33+ - class Future(Awaitable[_T]):
34+ + class Future(Awaitable[_T], Iterable[_T]):
35+ _state: str
36+ @property
37+ def _exception(self) -> BaseException | None: ...
1138diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
1239index 5c6d321f7..56a5969d1 100644
1340--- a/mypy/typeshed/stdlib/builtins.pyi
@@ -57,5 +84,241 @@ index 5c6d321f7..56a5969d1 100644
5784 if sys.version_info >= (3, 10):
5885 @overload
5986 def __new__(cls, *, strict: bool = ...) -> zip[Any]: ...
87+ diff --git a/mypy/typeshed/stdlib/csv.pyi b/mypy/typeshed/stdlib/csv.pyi
88+ index 4a82de638..ef93129d6 100644
89+ --- a/mypy/typeshed/stdlib/csv.pyi
90+ +++ b/mypy/typeshed/stdlib/csv.pyi
91+ @@ -25,7 +25,7 @@ else:
92+ from _csv import _reader as Reader, _writer as Writer
93+
94+ from _typeshed import SupportsWrite
95+ - from collections.abc import Collection, Iterable, Mapping, Sequence
96+ + from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence
97+ from typing import Any, Generic, Literal, TypeVar, overload
98+ from typing_extensions import Self
99+
100+ @@ -75,7 +75,7 @@ class excel(Dialect): ...
101+ class excel_tab(excel): ...
102+ class unix_dialect(Dialect): ...
103+
104+ - class DictReader(Generic[_T]):
105+ + class DictReader(Iterator[dict[_T | Any, str | Any]], Generic[_T]):
106+ fieldnames: Sequence[_T] | None
107+ restkey: _T | None
108+ restval: str | Any | None
109+ diff --git a/mypy/typeshed/stdlib/fileinput.pyi b/mypy/typeshed/stdlib/fileinput.pyi
110+ index bf6daad0a..1e6aa78e2 100644
111+ --- a/mypy/typeshed/stdlib/fileinput.pyi
112+ +++ b/mypy/typeshed/stdlib/fileinput.pyi
113+ @@ -1,8 +1,8 @@
114+ import sys
115+ from _typeshed import AnyStr_co, StrOrBytesPath
116+ - from collections.abc import Callable, Iterable
117+ + from collections.abc import Callable, Iterable, Iterator
118+ from types import TracebackType
119+ - from typing import IO, Any, AnyStr, Generic, Literal, Protocol, overload
120+ + from typing import IO, Any, AnyStr, Literal, Protocol, overload
121+ from typing_extensions import Self, TypeAlias
122+
123+ if sys.version_info >= (3, 9):
124+ @@ -107,7 +107,7 @@ def fileno() -> int: ...
125+ def isfirstline() -> bool: ...
126+ def isstdin() -> bool: ...
127+
128+ - class FileInput(Generic[AnyStr]):
129+ + class FileInput(Iterator[AnyStr]):
130+ if sys.version_info >= (3, 10):
131+ # encoding and errors are added
132+ @overload
133+ diff --git a/mypy/typeshed/stdlib/itertools.pyi b/mypy/typeshed/stdlib/itertools.pyi
134+ index 013c3cba1..f69665882 100644
135+ --- a/mypy/typeshed/stdlib/itertools.pyi
136+ +++ b/mypy/typeshed/stdlib/itertools.pyi
137+ @@ -29,7 +29,7 @@ _Predicate: TypeAlias = Callable[[_T], object]
138+
139+ # Technically count can take anything that implements a number protocol and has an add method
140+ # but we can't enforce the add method
141+ - class count(Generic[_N]):
142+ + class count(Iterator[_N]):
143+ @overload
144+ def __new__(cls) -> count[int]: ...
145+ @overload
146+ @@ -39,12 +39,12 @@ class count(Generic[_N]):
147+ def __next__(self) -> _N: ...
148+ def __iter__(self) -> Self: ...
149+
150+ - class cycle(Generic[_T]):
151+ + class cycle(Iterator[_T]):
152+ def __init__(self, iterable: Iterable[_T], /) -> None: ...
153+ def __next__(self) -> _T: ...
154+ def __iter__(self) -> Self: ...
155+
156+ - class repeat(Generic[_T]):
157+ + class repeat(Iterator[_T]):
158+ @overload
159+ def __init__(self, object: _T) -> None: ...
160+ @overload
161+ @@ -53,7 +53,7 @@ class repeat(Generic[_T]):
162+ def __iter__(self) -> Self: ...
163+ def __length_hint__(self) -> int: ...
164+
165+ - class accumulate(Generic[_T]):
166+ + class accumulate(Iterator[_T]):
167+ @overload
168+ def __init__(self, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> None: ...
169+ @overload
170+ @@ -61,7 +61,7 @@ class accumulate(Generic[_T]):
171+ def __iter__(self) -> Self: ...
172+ def __next__(self) -> _T: ...
173+
174+ - class chain(Generic[_T]):
175+ + class chain(Iterator[_T]):
176+ def __init__(self, *iterables: Iterable[_T]) -> None: ...
177+ def __next__(self) -> _T: ...
178+ def __iter__(self) -> Self: ...
179+ @@ -71,22 +71,22 @@ class chain(Generic[_T]):
180+ if sys.version_info >= (3, 9):
181+ def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
182+
183+ - class compress(Generic[_T]):
184+ + class compress(Iterator[_T]):
185+ def __init__(self, data: Iterable[_T], selectors: Iterable[Any]) -> None: ...
186+ def __iter__(self) -> Self: ...
187+ def __next__(self) -> _T: ...
188+
189+ - class dropwhile(Generic[_T]):
190+ + class dropwhile(Iterator[_T]):
191+ def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
192+ def __iter__(self) -> Self: ...
193+ def __next__(self) -> _T: ...
194+
195+ - class filterfalse(Generic[_T]):
196+ + class filterfalse(Iterator[_T]):
197+ def __init__(self, predicate: _Predicate[_T] | None, iterable: Iterable[_T], /) -> None: ...
198+ def __iter__(self) -> Self: ...
199+ def __next__(self) -> _T: ...
200+
201+ - class groupby(Generic[_T_co, _S_co]):
202+ + class groupby(Iterator[tuple[_T_co, Iterator[_S_co]]], Generic[_T_co, _S_co]):
203+ @overload
204+ def __new__(cls, iterable: Iterable[_T1], key: None = None) -> groupby[_T1, _T1]: ...
205+ @overload
206+ @@ -94,7 +94,7 @@ class groupby(Generic[_T_co, _S_co]):
207+ def __iter__(self) -> Self: ...
208+ def __next__(self) -> tuple[_T_co, Iterator[_S_co]]: ...
209+
210+ - class islice(Generic[_T]):
211+ + class islice(Iterator[_T]):
212+ @overload
213+ def __init__(self, iterable: Iterable[_T], stop: int | None, /) -> None: ...
214+ @overload
215+ @@ -102,19 +102,19 @@ class islice(Generic[_T]):
216+ def __iter__(self) -> Self: ...
217+ def __next__(self) -> _T: ...
218+
219+ - class starmap(Generic[_T_co]):
220+ + class starmap(Iterator[_T_co]):
221+ def __new__(cls, function: Callable[..., _T], iterable: Iterable[Iterable[Any]], /) -> starmap[_T]: ...
222+ def __iter__(self) -> Self: ...
223+ def __next__(self) -> _T_co: ...
224+
225+ - class takewhile(Generic[_T]):
226+ + class takewhile(Iterator[_T]):
227+ def __init__(self, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> None: ...
228+ def __iter__(self) -> Self: ...
229+ def __next__(self) -> _T: ...
230+
231+ def tee(iterable: Iterable[_T], n: int = 2, /) -> tuple[Iterator[_T], ...]: ...
232+
233+ - class zip_longest(Generic[_T_co]):
234+ + class zip_longest(Iterator[_T_co]):
235+ # one iterable (fillvalue doesn't matter)
236+ @overload
237+ def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = ...) -> zip_longest[tuple[_T1]]: ...
238+ @@ -192,7 +192,7 @@ class zip_longest(Generic[_T_co]):
239+ def __iter__(self) -> Self: ...
240+ def __next__(self) -> _T_co: ...
241+
242+ - class product(Generic[_T_co]):
243+ + class product(Iterator[_T_co]):
244+ @overload
245+ def __new__(cls, iter1: Iterable[_T1], /) -> product[tuple[_T1]]: ...
246+ @overload
247+ @@ -277,7 +277,7 @@ class product(Generic[_T_co]):
248+ def __iter__(self) -> Self: ...
249+ def __next__(self) -> _T_co: ...
250+
251+ - class permutations(Generic[_T_co]):
252+ + class permutations(Iterator[_T_co]):
253+ @overload
254+ def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> permutations[tuple[_T, _T]]: ...
255+ @overload
256+ @@ -291,7 +291,7 @@ class permutations(Generic[_T_co]):
257+ def __iter__(self) -> Self: ...
258+ def __next__(self) -> _T_co: ...
259+
260+ - class combinations(Generic[_T_co]):
261+ + class combinations(Iterator[_T_co]):
262+ @overload
263+ def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations[tuple[_T, _T]]: ...
264+ @overload
265+ @@ -305,7 +305,7 @@ class combinations(Generic[_T_co]):
266+ def __iter__(self) -> Self: ...
267+ def __next__(self) -> _T_co: ...
268+
269+ - class combinations_with_replacement(Generic[_T_co]):
270+ + class combinations_with_replacement(Iterator[_T_co]):
271+ @overload
272+ def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations_with_replacement[tuple[_T, _T]]: ...
273+ @overload
274+ @@ -320,13 +320,13 @@ class combinations_with_replacement(Generic[_T_co]):
275+ def __next__(self) -> _T_co: ...
276+
277+ if sys.version_info >= (3, 10):
278+ - class pairwise(Generic[_T_co]):
279+ + class pairwise(Iterator[_T_co]):
280+ def __new__(cls, iterable: Iterable[_T], /) -> pairwise[tuple[_T, _T]]: ...
281+ def __iter__(self) -> Self: ...
282+ def __next__(self) -> _T_co: ...
283+
284+ if sys.version_info >= (3, 12):
285+ - class batched(Generic[_T_co]):
286+ + class batched(Iterator[tuple[_T_co, ...]], Generic[_T_co]):
287+ if sys.version_info >= (3, 13):
288+ def __new__(cls, iterable: Iterable[_T_co], n: int, *, strict: bool = False) -> Self: ...
289+ else:
290+ diff --git a/mypy/typeshed/stdlib/multiprocessing/pool.pyi b/mypy/typeshed/stdlib/multiprocessing/pool.pyi
291+ index 61d6d0781..950ed1d8c 100644
292+ --- a/mypy/typeshed/stdlib/multiprocessing/pool.pyi
293+ +++ b/mypy/typeshed/stdlib/multiprocessing/pool.pyi
294+ @@ -1,5 +1,5 @@
295+ import sys
296+ - from collections.abc import Callable, Iterable, Mapping
297+ + from collections.abc import Callable, Iterable, Iterator, Mapping
298+ from types import TracebackType
299+ from typing import Any, Final, Generic, TypeVar
300+ from typing_extensions import Self
301+ @@ -36,7 +36,7 @@ class MapResult(ApplyResult[list[_T]]):
302+ error_callback: Callable[[BaseException], object] | None,
303+ ) -> None: ...
304+
305+ - class IMapIterator(Generic[_T]):
306+ + class IMapIterator(Iterator[_T]):
307+ def __init__(self, pool: Pool) -> None: ...
308+ def __iter__(self) -> Self: ...
309+ def next(self, timeout: float | None = None) -> _T: ...
310+ diff --git a/mypy/typeshed/stdlib/sqlite3/__init__.pyi b/mypy/typeshed/stdlib/sqlite3/__init__.pyi
311+ index bc0ff6469..730404bde 100644
312+ --- a/mypy/typeshed/stdlib/sqlite3/__init__.pyi
313+ +++ b/mypy/typeshed/stdlib/sqlite3/__init__.pyi
314+ @@ -397,7 +397,7 @@ class Connection:
315+ self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None, /
316+ ) -> Literal[False]: ...
317+
318+ - class Cursor:
319+ + class Cursor(Iterator[Any]):
320+ arraysize: int
321+ @property
322+ def connection(self) -> Connection: ...
60323- -
613242.47.1
0 commit comments