Skip to content

Commit 41ec2b1

Browse files
cdce8pmypybot
authored and
mypybot
committed
Revert Remove redundant inheritances from Iterator in builtins
1 parent 9a743ac commit 41ec2b1

File tree

7 files changed

+34
-34
lines changed

7 files changed

+34
-34
lines changed

mypy/typeshed/stdlib/_asyncio.pyi

+2-2
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
66
from typing import Any, Literal, TextIO, TypeVar
@@ -13,7 +13,7 @@ _T = TypeVar("_T")
1313
_T_co = TypeVar("_T_co", covariant=True)
1414
_TaskYieldType: TypeAlias = Future[object] | None
1515

16-
class Future(Awaitable[_T]):
16+
class Future(Awaitable[_T], Iterable[_T]):
1717
_state: str
1818
@property
1919
def _exception(self) -> BaseException | None: ...

mypy/typeshed/stdlib/builtins.pyi

+5-5
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ class frozenset(AbstractSet[_T_co]):
11461146
if sys.version_info >= (3, 9):
11471147
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
11481148

1149-
class enumerate(Generic[_T]):
1149+
class enumerate(Iterator[tuple[int, _T]]):
11501150
def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ...
11511151
def __iter__(self) -> Self: ...
11521152
def __next__(self) -> tuple[int, _T]: ...
@@ -1340,7 +1340,7 @@ else:
13401340

13411341
exit: _sitebuiltins.Quitter
13421342

1343-
class filter(Generic[_T]):
1343+
class filter(Iterator[_T]):
13441344
@overload
13451345
def __new__(cls, function: None, iterable: Iterable[_T | None], /) -> Self: ...
13461346
@overload
@@ -1405,7 +1405,7 @@ license: _sitebuiltins._Printer
14051405

14061406
def locals() -> dict[str, Any]: ...
14071407

1408-
class map(Generic[_S]):
1408+
class map(Iterator[_S]):
14091409
@overload
14101410
def __new__(cls, func: Callable[[_T1], _S], iterable: Iterable[_T1], /) -> Self: ...
14111411
@overload
@@ -1648,7 +1648,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex
16481648

16491649
quit: _sitebuiltins.Quitter
16501650

1651-
class reversed(Generic[_T]):
1651+
class reversed(Iterator[_T]):
16521652
@overload
16531653
def __new__(cls, sequence: Reversible[_T], /) -> Iterator[_T]: ... # type: ignore[misc]
16541654
@overload
@@ -1709,7 +1709,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
17091709
@overload
17101710
def vars(object: Any = ..., /) -> dict[str, Any]: ...
17111711

1712-
class zip(Generic[_T_co]):
1712+
class zip(Iterator[_T_co]):
17131713
if sys.version_info >= (3, 10):
17141714
@overload
17151715
def __new__(cls, *, strict: bool = ...) -> zip[Any]: ...

mypy/typeshed/stdlib/csv.pyi

+2-2
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 typing import Any, Generic, Literal, TypeVar, overload
3030
from typing_extensions import Self
3131

@@ -75,7 +75,7 @@ class excel(Dialect): ...
7575
class excel_tab(excel): ...
7676
class unix_dialect(Dialect): ...
7777

78-
class DictReader(Generic[_T]):
78+
class DictReader(Iterator[dict[_T | Any, str | Any]], Generic[_T]):
7979
fieldnames: Sequence[_T] | None
8080
restkey: _T | None
8181
restval: str | Any | None

mypy/typeshed/stdlib/fileinput.pyi

+3-3
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 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
if sys.version_info >= (3, 9):
@@ -107,7 +107,7 @@ def fileno() -> int: ...
107107
def isfirstline() -> bool: ...
108108
def isstdin() -> bool: ...
109109

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

mypy/typeshed/stdlib/itertools.pyi

+19-19
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _Predicate: TypeAlias = Callable[[_T], object]
2929

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

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

47-
class repeat(Generic[_T]):
47+
class repeat(Iterator[_T]):
4848
@overload
4949
def __new__(cls, object: _T) -> Self: ...
5050
@overload
@@ -53,15 +53,15 @@ class repeat(Generic[_T]):
5353
def __iter__(self) -> Self: ...
5454
def __length_hint__(self) -> int: ...
5555

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

64-
class chain(Generic[_T]):
64+
class chain(Iterator[_T]):
6565
def __new__(cls, *iterables: Iterable[_T]) -> Self: ...
6666
def __next__(self) -> _T: ...
6767
def __iter__(self) -> Self: ...
@@ -71,50 +71,50 @@ class chain(Generic[_T]):
7171
if sys.version_info >= (3, 9):
7272
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
7373

74-
class compress(Generic[_T]):
74+
class compress(Iterator[_T]):
7575
def __new__(cls, data: Iterable[_T], selectors: Iterable[Any]) -> Self: ...
7676
def __iter__(self) -> Self: ...
7777
def __next__(self) -> _T: ...
7878

79-
class dropwhile(Generic[_T]):
79+
class dropwhile(Iterator[_T]):
8080
def __new__(cls, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> Self: ...
8181
def __iter__(self) -> Self: ...
8282
def __next__(self) -> _T: ...
8383

84-
class filterfalse(Generic[_T]):
84+
class filterfalse(Iterator[_T]):
8585
def __new__(cls, function: _Predicate[_T] | None, iterable: Iterable[_T], /) -> Self: ...
8686
def __iter__(self) -> Self: ...
8787
def __next__(self) -> _T: ...
8888

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

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

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

110-
class takewhile(Generic[_T]):
110+
class takewhile(Iterator[_T]):
111111
def __new__(cls, predicate: _Predicate[_T], iterable: Iterable[_T], /) -> Self: ...
112112
def __iter__(self) -> Self: ...
113113
def __next__(self) -> _T: ...
114114

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

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

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

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

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

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

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

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

mypy/typeshed/stdlib/multiprocessing/pool.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from collections.abc import Callable, Iterable, Mapping
2+
from collections.abc import Callable, Iterable, Iterator, Mapping
33
from multiprocessing.context import DefaultContext, Process
44
from types import TracebackType
55
from typing import Any, Final, Generic, TypeVar
@@ -37,7 +37,7 @@ class MapResult(ApplyResult[list[_T]]):
3737
error_callback: Callable[[BaseException], object] | None,
3838
) -> None: ...
3939

40-
class IMapIterator(Generic[_T]):
40+
class IMapIterator(Iterator[_T]):
4141
def __init__(self, pool: Pool) -> None: ...
4242
def __iter__(self) -> Self: ...
4343
def next(self, timeout: float | None = None) -> _T: ...

mypy/typeshed/stdlib/sqlite3/__init__.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class Connection:
397397
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None, /
398398
) -> Literal[False]: ...
399399

400-
class Cursor:
400+
class Cursor(Iterator[Any]):
401401
arraysize: int
402402
@property
403403
def connection(self) -> Connection: ...

0 commit comments

Comments
 (0)