Skip to content

Commit a08d4c8

Browse files
authored
Remove many redundant inheritances from Generic[] (#10933)
1 parent 5dbdd59 commit a08d4c8

File tree

30 files changed

+81
-81
lines changed

30 files changed

+81
-81
lines changed

stdlib/_collections_abc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented
8181
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
8282

8383
@final
84-
class dict_items(ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): # undocumented
84+
class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented
8585
def __eq__(self, __value: object) -> bool: ...
8686
if sys.version_info >= (3, 10):
8787
@property

stdlib/_weakrefset.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from collections.abc import Iterable, Iterator, MutableSet
3-
from typing import Any, Generic, TypeVar, overload
3+
from typing import Any, TypeVar, overload
44
from typing_extensions import Self
55

66
if sys.version_info >= (3, 9):
@@ -11,7 +11,7 @@ __all__ = ["WeakSet"]
1111
_S = TypeVar("_S")
1212
_T = TypeVar("_T")
1313

14-
class WeakSet(MutableSet[_T], Generic[_T]):
14+
class WeakSet(MutableSet[_T]):
1515
@overload
1616
def __init__(self, data: None = None) -> None: ...
1717
@overload

stdlib/array.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
33
from collections.abc import Iterable
44

55
# pytype crashes if array inherits from collections.abc.MutableSequence instead of typing.MutableSequence
6-
from typing import Any, Generic, MutableSequence, TypeVar, overload # noqa: Y022
6+
from typing import Any, MutableSequence, TypeVar, overload # noqa: Y022
77
from typing_extensions import Literal, Self, SupportsIndex, TypeAlias
88

99
if sys.version_info >= (3, 12):
@@ -18,7 +18,7 @@ _T = TypeVar("_T", int, float, str)
1818

1919
typecodes: str
2020

21-
class array(MutableSequence[_T], Generic[_T]):
21+
class array(MutableSequence[_T]):
2222
@property
2323
def typecode(self) -> _TypeCode: ...
2424
@property

stdlib/asyncio/tasks.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import concurrent.futures
22
import sys
33
from collections.abc import Awaitable, Coroutine, Generator, Iterable, Iterator
44
from types import FrameType
5-
from typing import Any, Generic, Protocol, TextIO, TypeVar, overload
5+
from typing import Any, Protocol, TextIO, TypeVar, overload
66
from typing_extensions import Literal, TypeAlias
77

88
from . import _CoroutineLike
@@ -379,7 +379,7 @@ else:
379379
# While this is true in general, here it's sort-of okay to have a covariant subclass,
380380
# since the only reason why `asyncio.Future` is invariant is the `set_result()` method,
381381
# and `asyncio.Task.set_result()` always raises.
382-
class Task(Future[_T_co], Generic[_T_co]): # type: ignore[type-var] # pyright: ignore[reportGeneralTypeIssues]
382+
class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportGeneralTypeIssues]
383383
if sys.version_info >= (3, 12):
384384
def __init__(
385385
self,

stdlib/builtins.pyi

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ class slice:
953953
__hash__: ClassVar[None] # type: ignore[assignment]
954954
def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ...
955955

956-
class tuple(Sequence[_T_co], Generic[_T_co]):
956+
class tuple(Sequence[_T_co]):
957957
def __new__(cls, __iterable: Iterable[_T_co] = ...) -> Self: ...
958958
def __len__(self) -> int: ...
959959
def __contains__(self, __key: object) -> bool: ...
@@ -1005,7 +1005,7 @@ class function:
10051005
# mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any.
10061006
def __get__(self, __instance: object, __owner: type | None = None) -> Any: ...
10071007

1008-
class list(MutableSequence[_T], Generic[_T]):
1008+
class list(MutableSequence[_T]):
10091009
@overload
10101010
def __init__(self) -> None: ...
10111011
@overload
@@ -1060,7 +1060,7 @@ class list(MutableSequence[_T], Generic[_T]):
10601060
if sys.version_info >= (3, 9):
10611061
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
10621062

1063-
class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
1063+
class dict(MutableMapping[_KT, _VT]):
10641064
# __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics
10651065
# Also multiprocessing.managers.SyncManager.dict()
10661066
@overload
@@ -1133,7 +1133,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
11331133
@overload
11341134
def __ior__(self, __value: Iterable[tuple[_KT, _VT]]) -> Self: ...
11351135

1136-
class set(MutableSet[_T], Generic[_T]):
1136+
class set(MutableSet[_T]):
11371137
@overload
11381138
def __init__(self) -> None: ...
11391139
@overload
@@ -1173,7 +1173,7 @@ class set(MutableSet[_T], Generic[_T]):
11731173
if sys.version_info >= (3, 9):
11741174
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
11751175

1176-
class frozenset(AbstractSet[_T_co], Generic[_T_co]):
1176+
class frozenset(AbstractSet[_T_co]):
11771177
@overload
11781178
def __new__(cls) -> Self: ...
11791179
@overload
@@ -1202,7 +1202,7 @@ class frozenset(AbstractSet[_T_co], Generic[_T_co]):
12021202
if sys.version_info >= (3, 9):
12031203
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
12041204

1205-
class enumerate(Iterator[tuple[int, _T]], Generic[_T]):
1205+
class enumerate(Iterator[tuple[int, _T]]):
12061206
def __new__(cls, iterable: Iterable[_T], start: int = ...) -> Self: ...
12071207
def __iter__(self) -> Self: ...
12081208
def __next__(self) -> tuple[int, _T]: ...
@@ -1411,7 +1411,7 @@ else:
14111411

14121412
def exit(code: sys._ExitCode = None) -> NoReturn: ...
14131413

1414-
class filter(Iterator[_T], Generic[_T]):
1414+
class filter(Iterator[_T]):
14151415
@overload
14161416
def __new__(cls, __function: None, __iterable: Iterable[_T | None]) -> Self: ...
14171417
@overload
@@ -1470,7 +1470,7 @@ def len(__obj: Sized) -> int: ...
14701470
def license() -> None: ...
14711471
def locals() -> dict[str, Any]: ...
14721472

1473-
class map(Iterator[_S], Generic[_S]):
1473+
class map(Iterator[_S]):
14741474
@overload
14751475
def __new__(cls, __func: Callable[[_T1], _S], __iter1: Iterable[_T1]) -> Self: ...
14761476
@overload
@@ -1742,7 +1742,7 @@ else:
17421742

17431743
def quit(code: sys._ExitCode = None) -> NoReturn: ...
17441744

1745-
class reversed(Iterator[_T], Generic[_T]):
1745+
class reversed(Iterator[_T]):
17461746
@overload
17471747
def __init__(self, __sequence: Reversible[_T]) -> None: ...
17481748
@overload
@@ -1816,7 +1816,7 @@ def vars(__object: type) -> types.MappingProxyType[str, Any]: ... # type: ignor
18161816
@overload
18171817
def vars(__object: Any = ...) -> dict[str, Any]: ...
18181818

1819-
class zip(Iterator[_T_co], Generic[_T_co]):
1819+
class zip(Iterator[_T_co]):
18201820
if sys.version_info >= (3, 10):
18211821
@overload
18221822
def __new__(cls, *, strict: bool = ...) -> zip[Any]: ...

stdlib/collections/__init__.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def namedtuple(
4545
defaults: Iterable[Any] | None = None,
4646
) -> type[tuple[Any, ...]]: ...
4747

48-
class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
48+
class UserDict(MutableMapping[_KT, _VT]):
4949
data: dict[_KT, _VT]
5050
# __init__ should be kept roughly in line with `dict.__init__`, which has the same semantics
5151
@overload
@@ -228,7 +228,7 @@ class UserString(Sequence[UserString]):
228228
def upper(self) -> Self: ...
229229
def zfill(self, width: int) -> Self: ...
230230

231-
class deque(MutableSequence[_T], Generic[_T]):
231+
class deque(MutableSequence[_T]):
232232
@property
233233
def maxlen(self) -> int | None: ...
234234
@overload
@@ -383,7 +383,7 @@ class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
383383
@overload
384384
def __ror__(self, __value: dict[_T1, _T2]) -> OrderedDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
385385

386-
class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
386+
class defaultdict(dict[_KT, _VT]):
387387
default_factory: Callable[[], _VT] | None
388388
@overload
389389
def __init__(self) -> None: ...
@@ -424,7 +424,7 @@ class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
424424
@overload
425425
def __ror__(self, __value: dict[_T1, _T2]) -> defaultdict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
426426

427-
class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
427+
class ChainMap(MutableMapping[_KT, _VT]):
428428
maps: list[MutableMapping[_KT, _VT]]
429429
def __init__(self, *maps: MutableMapping[_KT, _VT]) -> None: ...
430430
def new_child(self, m: MutableMapping[_KT, _VT] | None = None) -> Self: ...

stdlib/contextlib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ if sys.version_info >= (3, 10):
9494
) -> bool | None: ...
9595

9696
else:
97-
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]):
97+
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co]):
9898
def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...
9999
gen: AsyncGenerator[_T_co, Any]
100100
func: Callable[..., AsyncGenerator[_T_co, Any]]

stdlib/fileinput.pyi

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

88
if sys.version_info >= (3, 9):
@@ -158,7 +158,7 @@ def fileno() -> int: ...
158158
def isfirstline() -> bool: ...
159159
def isstdin() -> bool: ...
160160

161-
class FileInput(Iterator[AnyStr], Generic[AnyStr]):
161+
class FileInput(Iterator[AnyStr]):
162162
if sys.version_info >= (3, 10):
163163
# encoding and errors are added
164164
@overload

stdlib/itertools.pyi

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

2424
# Technically count can take anything that implements a number protocol and has an add method
2525
# but we can't enforce the add method
26-
class count(Iterator[_N], Generic[_N]):
26+
class count(Iterator[_N]):
2727
@overload
2828
def __new__(cls) -> count[int]: ...
2929
@overload
@@ -33,12 +33,12 @@ class count(Iterator[_N], Generic[_N]):
3333
def __next__(self) -> _N: ...
3434
def __iter__(self) -> Self: ...
3535

36-
class cycle(Iterator[_T], Generic[_T]):
36+
class cycle(Iterator[_T]):
3737
def __init__(self, __iterable: Iterable[_T]) -> None: ...
3838
def __next__(self) -> _T: ...
3939
def __iter__(self) -> Self: ...
4040

41-
class repeat(Iterator[_T], Generic[_T]):
41+
class repeat(Iterator[_T]):
4242
@overload
4343
def __init__(self, object: _T) -> None: ...
4444
@overload
@@ -47,7 +47,7 @@ class repeat(Iterator[_T], Generic[_T]):
4747
def __iter__(self) -> Self: ...
4848
def __length_hint__(self) -> int: ...
4949

50-
class accumulate(Iterator[_T], Generic[_T]):
50+
class accumulate(Iterator[_T]):
5151
if sys.version_info >= (3, 8):
5252
@overload
5353
def __init__(self, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> None: ...
@@ -59,7 +59,7 @@ class accumulate(Iterator[_T], Generic[_T]):
5959
def __iter__(self) -> Self: ...
6060
def __next__(self) -> _T: ...
6161

62-
class chain(Iterator[_T], Generic[_T]):
62+
class chain(Iterator[_T]):
6363
def __init__(self, *iterables: Iterable[_T]) -> None: ...
6464
def __next__(self) -> _T: ...
6565
def __iter__(self) -> Self: ...
@@ -69,17 +69,17 @@ class chain(Iterator[_T], Generic[_T]):
6969
if sys.version_info >= (3, 9):
7070
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
7171

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

77-
class dropwhile(Iterator[_T], Generic[_T]):
77+
class dropwhile(Iterator[_T]):
7878
def __init__(self, __predicate: _Predicate[_T], __iterable: Iterable[_T]) -> None: ...
7979
def __iter__(self) -> Self: ...
8080
def __next__(self) -> _T: ...
8181

82-
class filterfalse(Iterator[_T], Generic[_T]):
82+
class filterfalse(Iterator[_T]):
8383
def __init__(self, __predicate: _Predicate[_T] | None, __iterable: Iterable[_T]) -> None: ...
8484
def __iter__(self) -> Self: ...
8585
def __next__(self) -> _T: ...
@@ -92,27 +92,27 @@ class groupby(Iterator[tuple[_T, Iterator[_S]]], Generic[_T, _S]):
9292
def __iter__(self) -> Self: ...
9393
def __next__(self) -> tuple[_T, Iterator[_S]]: ...
9494

95-
class islice(Iterator[_T], Generic[_T]):
95+
class islice(Iterator[_T]):
9696
@overload
9797
def __init__(self, __iterable: Iterable[_T], __stop: int | None) -> None: ...
9898
@overload
9999
def __init__(self, __iterable: Iterable[_T], __start: int | None, __stop: int | None, __step: int | None = ...) -> None: ...
100100
def __iter__(self) -> Self: ...
101101
def __next__(self) -> _T: ...
102102

103-
class starmap(Iterator[_T], Generic[_T]):
103+
class starmap(Iterator[_T]):
104104
def __init__(self, __function: Callable[..., _T], __iterable: Iterable[Iterable[Any]]) -> None: ...
105105
def __iter__(self) -> Self: ...
106106
def __next__(self) -> _T: ...
107107

108-
class takewhile(Iterator[_T], Generic[_T]):
108+
class takewhile(Iterator[_T]):
109109
def __init__(self, __predicate: _Predicate[_T], __iterable: Iterable[_T]) -> None: ...
110110
def __iter__(self) -> Self: ...
111111
def __next__(self) -> _T: ...
112112

113113
def tee(__iterable: Iterable[_T], __n: int = 2) -> tuple[Iterator[_T], ...]: ...
114114

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

195-
class product(Iterator[_T_co], Generic[_T_co]):
195+
class product(Iterator[_T_co]):
196196
@overload
197197
def __new__(cls, __iter1: Iterable[_T1]) -> product[tuple[_T1]]: ...
198198
@overload
@@ -246,7 +246,7 @@ class permutations(Iterator[tuple[_T, ...]], Generic[_T]):
246246
def __iter__(self) -> Self: ...
247247
def __next__(self) -> tuple[_T, ...]: ...
248248

249-
class combinations(Iterator[_T_co], Generic[_T_co]):
249+
class combinations(Iterator[_T_co]):
250250
@overload
251251
def __new__(cls, iterable: Iterable[_T], r: Literal[2]) -> combinations[tuple[_T, _T]]: ...
252252
@overload
@@ -266,7 +266,7 @@ class combinations_with_replacement(Iterator[tuple[_T, ...]], Generic[_T]):
266266
def __next__(self) -> tuple[_T, ...]: ...
267267

268268
if sys.version_info >= (3, 10):
269-
class pairwise(Iterator[_T_co], Generic[_T_co]):
269+
class pairwise(Iterator[_T_co]):
270270
def __new__(cls, __iterable: Iterable[_T]) -> pairwise[tuple[_T, _T]]: ...
271271
def __iter__(self) -> Self: ...
272272
def __next__(self) -> _T_co: ...

stdlib/tempfile.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ else:
321321
dir: GenericPath[AnyStr] | None = None,
322322
) -> IO[Any]: ...
323323

324-
class _TemporaryFileWrapper(IO[AnyStr], Generic[AnyStr]):
324+
class _TemporaryFileWrapper(IO[AnyStr]):
325325
file: IO[AnyStr] # io.TextIOWrapper, io.BufferedReader or io.BufferedWriter
326326
name: str
327327
delete: bool

0 commit comments

Comments
 (0)