Skip to content

Commit 939d311

Browse files
cdce8pmypybot
authored andcommitted
Revert Remove redundant inheritances from Iterator in builtins
1 parent 9d23513 commit 939d311

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
@@ -10,7 +10,7 @@ _T = TypeVar("_T")
1010
_T_co = TypeVar("_T_co", covariant=True)
1111
_TaskYieldType: TypeAlias = Future[object] | None
1212

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

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ class frozenset(AbstractSet[_T_co]):
11841184
def __hash__(self) -> int: ...
11851185
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
11861186

1187-
class enumerate(Generic[_T]):
1187+
class enumerate(Iterator[tuple[int, _T]]):
11881188
def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ...
11891189
def __iter__(self) -> Self: ...
11901190
def __next__(self) -> tuple[int, _T]: ...
@@ -1375,7 +1375,7 @@ else:
13751375

13761376
exit: _sitebuiltins.Quitter
13771377

1378-
class filter(Generic[_T]):
1378+
class filter(Iterator[_T]):
13791379
@overload
13801380
def __new__(cls, function: None, iterable: Iterable[_T | None], /) -> Self: ...
13811381
@overload
@@ -1440,7 +1440,7 @@ license: _sitebuiltins._Printer
14401440

14411441
def locals() -> dict[str, Any]: ...
14421442

1443-
class map(Generic[_S]):
1443+
class map(Iterator[_S]):
14441444
# 3.14 adds `strict` argument.
14451445
if sys.version_info >= (3, 14):
14461446
@overload
@@ -1743,7 +1743,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex
17431743

17441744
quit: _sitebuiltins.Quitter
17451745

1746-
class reversed(Generic[_T]):
1746+
class reversed(Iterator[_T]):
17471747
@overload
17481748
def __new__(cls, sequence: Reversible[_T], /) -> Iterator[_T]: ... # type: ignore[misc]
17491749
@overload
@@ -1804,7 +1804,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
18041804
@overload
18051805
def vars(object: Any = ..., /) -> dict[str, Any]: ...
18061806

1807-
class zip(Generic[_T_co]):
1807+
class zip(Iterator[_T_co]):
18081808
if sys.version_info >= (3, 10):
18091809
@overload
18101810
def __new__(cls, *, strict: bool = ...) -> 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
5+
from typing import IO, Any, AnyStr, Literal, Protocol, overload
66
from typing_extensions import Self, TypeAlias
77

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

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

mypy/typeshed/stdlib/itertools.pyi

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

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
30-
class count(Generic[_N]):
30+
class count(Iterator[_N]):
3131
@overload
3232
def __new__(cls) -> count[int]: ...
3333
@overload
@@ -37,12 +37,12 @@ class count(Generic[_N]):
3737
def __next__(self) -> _N: ...
3838
def __iter__(self) -> Self: ...
3939

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

45-
class repeat(Generic[_T]):
45+
class repeat(Iterator[_T]):
4646
@overload
4747
def __new__(cls, object: _T) -> Self: ...
4848
@overload
@@ -51,15 +51,15 @@ class repeat(Generic[_T]):
5151
def __iter__(self) -> Self: ...
5252
def __length_hint__(self) -> int: ...
5353

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

62-
class chain(Generic[_T]):
62+
class chain(Iterator[_T]):
6363
def __new__(cls, *iterables: Iterable[_T]) -> Self: ...
6464
def __next__(self) -> _T: ...
6565
def __iter__(self) -> Self: ...
@@ -68,50 +68,50 @@ class chain(Generic[_T]):
6868
def from_iterable(cls: type[Any], iterable: Iterable[Iterable[_S]], /) -> chain[_S]: ...
6969
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
7070

71-
class compress(Generic[_T]):
71+
class compress(Iterator[_T]):
7272
def __new__(cls, data: Iterable[_T], selectors: Iterable[Any]) -> Self: ...
7373
def __iter__(self) -> Self: ...
7474
def __next__(self) -> _T: ...
7575

76-
class dropwhile(Generic[_T]):
76+
class dropwhile(Iterator[_T]):
7777
def __new__(cls, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> Self: ...
7878
def __iter__(self) -> Self: ...
7979
def __next__(self) -> _T: ...
8080

81-
class filterfalse(Generic[_T]):
81+
class filterfalse(Iterator[_T]):
8282
def __new__(cls, function: _Predicate[_T] | None, iterable: Iterable[_T], /) -> Self: ...
8383
def __iter__(self) -> Self: ...
8484
def __next__(self) -> _T: ...
8585

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

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

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

107-
class takewhile(Generic[_T]):
107+
class takewhile(Iterator[_T]):
108108
def __new__(cls, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> Self: ...
109109
def __iter__(self) -> Self: ...
110110
def __next__(self) -> _T: ...
111111

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

114-
class zip_longest(Generic[_T_co]):
114+
class zip_longest(Iterator[_T_co]):
115115
# one iterable (fillvalue doesn't matter)
116116
@overload
117117
def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = ...) -> zip_longest[tuple[_T1]]: ...
@@ -189,7 +189,7 @@ class zip_longest(Generic[_T_co]):
189189
def __iter__(self) -> Self: ...
190190
def __next__(self) -> _T_co: ...
191191

192-
class product(Generic[_T_co]):
192+
class product(Iterator[_T_co]):
193193
@overload
194194
def __new__(cls, iter1: Iterable[_T1], /) -> product[tuple[_T1]]: ...
195195
@overload
@@ -274,7 +274,7 @@ class product(Generic[_T_co]):
274274
def __iter__(self) -> Self: ...
275275
def __next__(self) -> _T_co: ...
276276

277-
class permutations(Generic[_T_co]):
277+
class permutations(Iterator[_T_co]):
278278
@overload
279279
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> permutations[tuple[_T, _T]]: ...
280280
@overload
@@ -288,7 +288,7 @@ class permutations(Generic[_T_co]):
288288
def __iter__(self) -> Self: ...
289289
def __next__(self) -> _T_co: ...
290290

291-
class combinations(Generic[_T_co]):
291+
class combinations(Iterator[_T_co]):
292292
@overload
293293
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations[tuple[_T, _T]]: ...
294294
@overload
@@ -302,7 +302,7 @@ class combinations(Generic[_T_co]):
302302
def __iter__(self) -> Self: ...
303303
def __next__(self) -> _T_co: ...
304304

305-
class combinations_with_replacement(Generic[_T_co]):
305+
class combinations_with_replacement(Iterator[_T_co]):
306306
@overload
307307
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations_with_replacement[tuple[_T, _T]]: ...
308308
@overload
@@ -317,13 +317,13 @@ class combinations_with_replacement(Generic[_T_co]):
317317
def __next__(self) -> _T_co: ...
318318

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

325325
if sys.version_info >= (3, 12):
326-
class batched(Generic[_T_co]):
326+
class batched(Iterator[tuple[_T_co, ...]], Generic[_T_co]):
327327
if sys.version_info >= (3, 13):
328328
def __new__(cls, iterable: Iterable[_T_co], n: int, *, strict: bool = False) -> Self: ...
329329
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
@@ -399,7 +399,7 @@ class Connection:
399399
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None, /
400400
) -> Literal[False]: ...
401401

402-
class Cursor:
402+
class Cursor(Iterator[Any]):
403403
arraysize: int
404404
@property
405405
def connection(self) -> Connection: ...

0 commit comments

Comments
 (0)