Skip to content

Commit 10febc4

Browse files
authored
stdlib: remove unused type: ignore comments (#11061)
1 parent c2c8d7c commit 10febc4

File tree

19 files changed

+76
-72
lines changed

19 files changed

+76
-72
lines changed

stdlib/_codecs.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ _StrToStrEncoding: TypeAlias = Literal["rot13", "rot_13"]
4747
@overload
4848
def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ...
4949
@overload
50-
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[misc]
50+
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[overload-overlap]
5151
@overload
5252
def encode(obj: str, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
5353
@overload
54-
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[misc]
54+
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[overload-overlap]
5555
@overload
5656
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ...
5757

stdlib/argparse.pyi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
172172
) -> None: ...
173173

174174
@overload
175-
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... # type: ignore[misc]
175+
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
176176
@overload
177177
def parse_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
178178
@overload
@@ -211,7 +211,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
211211
def format_usage(self) -> str: ...
212212
def format_help(self) -> str: ...
213213
@overload
214-
def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
214+
def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ...
215215
@overload
216216
def parse_known_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
217217
@overload
@@ -220,13 +220,15 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
220220
def exit(self, status: int = 0, message: str | None = None) -> NoReturn: ...
221221
def error(self, message: str) -> NoReturn: ...
222222
@overload
223-
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... # type: ignore[misc]
223+
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
224224
@overload
225225
def parse_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
226226
@overload
227227
def parse_intermixed_args(self, *, namespace: _N) -> _N: ...
228228
@overload
229-
def parse_known_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
229+
def parse_known_intermixed_args(
230+
self, args: Sequence[str] | None = None, namespace: None = None
231+
) -> tuple[Namespace, list[str]]: ...
230232
@overload
231233
def parse_known_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
232234
@overload

stdlib/asyncio/tasks.pyi

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ else:
8686
) -> Iterator[Future[_T]]: ...
8787

8888
@overload
89-
def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[misc]
89+
def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[overload-overlap]
9090
@overload
9191
def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = None) -> Task[_T]: ...
9292

@@ -95,25 +95,24 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No
9595
# zip() because typing does not support variadic type variables. See
9696
# typing PR #1550 for discussion.
9797
#
98-
# The many type: ignores here are because the overloads overlap,
99-
# but having overlapping overloads is the only way to get acceptable type inference in all edge cases.
98+
# N.B. Having overlapping overloads is the only way to get acceptable type inference in all edge cases.
10099
if sys.version_info >= (3, 10):
101100
@overload
102-
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[misc]
101+
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap]
103102
@overload
104-
def gather( # type: ignore[misc]
103+
def gather( # type: ignore[overload-overlap]
105104
__coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, return_exceptions: Literal[False] = False
106105
) -> Future[tuple[_T1, _T2]]: ...
107106
@overload
108-
def gather( # type: ignore[misc]
107+
def gather( # type: ignore[overload-overlap]
109108
__coro_or_future1: _FutureLike[_T1],
110109
__coro_or_future2: _FutureLike[_T2],
111110
__coro_or_future3: _FutureLike[_T3],
112111
*,
113112
return_exceptions: Literal[False] = False,
114113
) -> Future[tuple[_T1, _T2, _T3]]: ...
115114
@overload
116-
def gather( # type: ignore[misc]
115+
def gather( # type: ignore[overload-overlap]
117116
__coro_or_future1: _FutureLike[_T1],
118117
__coro_or_future2: _FutureLike[_T2],
119118
__coro_or_future3: _FutureLike[_T3],
@@ -122,7 +121,7 @@ if sys.version_info >= (3, 10):
122121
return_exceptions: Literal[False] = False,
123122
) -> Future[tuple[_T1, _T2, _T3, _T4]]: ...
124123
@overload
125-
def gather( # type: ignore[misc]
124+
def gather( # type: ignore[overload-overlap]
126125
__coro_or_future1: _FutureLike[_T1],
127126
__coro_or_future2: _FutureLike[_T2],
128127
__coro_or_future3: _FutureLike[_T3],
@@ -132,7 +131,7 @@ if sys.version_info >= (3, 10):
132131
return_exceptions: Literal[False] = False,
133132
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
134133
@overload
135-
def gather( # type: ignore[misc]
134+
def gather( # type: ignore[overload-overlap]
136135
__coro_or_future1: _FutureLike[_T1],
137136
__coro_or_future2: _FutureLike[_T2],
138137
__coro_or_future3: _FutureLike[_T3],
@@ -143,23 +142,23 @@ if sys.version_info >= (3, 10):
143142
return_exceptions: Literal[False] = False,
144143
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
145144
@overload
146-
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[misc]
145+
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap]
147146
@overload
148-
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[misc]
147+
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[overload-overlap]
149148
@overload
150-
def gather( # type: ignore[misc]
149+
def gather( # type: ignore[overload-overlap]
151150
__coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, return_exceptions: bool
152151
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
153152
@overload
154-
def gather( # type: ignore[misc]
153+
def gather( # type: ignore[overload-overlap]
155154
__coro_or_future1: _FutureLike[_T1],
156155
__coro_or_future2: _FutureLike[_T2],
157156
__coro_or_future3: _FutureLike[_T3],
158157
*,
159158
return_exceptions: bool,
160159
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
161160
@overload
162-
def gather( # type: ignore[misc]
161+
def gather( # type: ignore[overload-overlap]
163162
__coro_or_future1: _FutureLike[_T1],
164163
__coro_or_future2: _FutureLike[_T2],
165164
__coro_or_future3: _FutureLike[_T3],
@@ -168,7 +167,7 @@ if sys.version_info >= (3, 10):
168167
return_exceptions: bool,
169168
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
170169
@overload
171-
def gather( # type: ignore[misc]
170+
def gather( # type: ignore[overload-overlap]
172171
__coro_or_future1: _FutureLike[_T1],
173172
__coro_or_future2: _FutureLike[_T2],
174173
__coro_or_future3: _FutureLike[_T3],
@@ -180,7 +179,7 @@ if sys.version_info >= (3, 10):
180179
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
181180
]: ...
182181
@overload
183-
def gather( # type: ignore[misc]
182+
def gather( # type: ignore[overload-overlap]
184183
__coro_or_future1: _FutureLike[_T1],
185184
__coro_or_future2: _FutureLike[_T2],
186185
__coro_or_future3: _FutureLike[_T3],
@@ -204,19 +203,19 @@ if sys.version_info >= (3, 10):
204203

205204
else:
206205
@overload
207-
def gather( # type: ignore[misc]
206+
def gather( # type: ignore[overload-overlap]
208207
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False
209208
) -> Future[tuple[_T1]]: ...
210209
@overload
211-
def gather( # type: ignore[misc]
210+
def gather( # type: ignore[overload-overlap]
212211
__coro_or_future1: _FutureLike[_T1],
213212
__coro_or_future2: _FutureLike[_T2],
214213
*,
215214
loop: AbstractEventLoop | None = None,
216215
return_exceptions: Literal[False] = False,
217216
) -> Future[tuple[_T1, _T2]]: ...
218217
@overload
219-
def gather( # type: ignore[misc]
218+
def gather( # type: ignore[overload-overlap]
220219
__coro_or_future1: _FutureLike[_T1],
221220
__coro_or_future2: _FutureLike[_T2],
222221
__coro_or_future3: _FutureLike[_T3],
@@ -225,7 +224,7 @@ else:
225224
return_exceptions: Literal[False] = False,
226225
) -> Future[tuple[_T1, _T2, _T3]]: ...
227226
@overload
228-
def gather( # type: ignore[misc]
227+
def gather( # type: ignore[overload-overlap]
229228
__coro_or_future1: _FutureLike[_T1],
230229
__coro_or_future2: _FutureLike[_T2],
231230
__coro_or_future3: _FutureLike[_T3],
@@ -235,7 +234,7 @@ else:
235234
return_exceptions: Literal[False] = False,
236235
) -> Future[tuple[_T1, _T2, _T3, _T4]]: ...
237236
@overload
238-
def gather( # type: ignore[misc]
237+
def gather( # type: ignore[overload-overlap]
239238
__coro_or_future1: _FutureLike[_T1],
240239
__coro_or_future2: _FutureLike[_T2],
241240
__coro_or_future3: _FutureLike[_T3],
@@ -246,7 +245,7 @@ else:
246245
return_exceptions: Literal[False] = False,
247246
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
248247
@overload
249-
def gather( # type: ignore[misc]
248+
def gather( # type: ignore[overload-overlap]
250249
__coro_or_future1: _FutureLike[_T1],
251250
__coro_or_future2: _FutureLike[_T2],
252251
__coro_or_future3: _FutureLike[_T3],
@@ -258,23 +257,23 @@ else:
258257
return_exceptions: Literal[False] = False,
259258
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
260259
@overload
261-
def gather( # type: ignore[misc]
260+
def gather( # type: ignore[overload-overlap]
262261
*coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False
263262
) -> Future[list[_T]]: ...
264263
@overload
265-
def gather( # type: ignore[misc]
264+
def gather( # type: ignore[overload-overlap]
266265
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = None, return_exceptions: bool
267266
) -> Future[tuple[_T1 | BaseException]]: ...
268267
@overload
269-
def gather( # type: ignore[misc]
268+
def gather( # type: ignore[overload-overlap]
270269
__coro_or_future1: _FutureLike[_T1],
271270
__coro_or_future2: _FutureLike[_T2],
272271
*,
273272
loop: AbstractEventLoop | None = None,
274273
return_exceptions: bool,
275274
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
276275
@overload
277-
def gather( # type: ignore[misc]
276+
def gather( # type: ignore[overload-overlap]
278277
__coro_or_future1: _FutureLike[_T1],
279278
__coro_or_future2: _FutureLike[_T2],
280279
__coro_or_future3: _FutureLike[_T3],
@@ -283,7 +282,7 @@ else:
283282
return_exceptions: bool,
284283
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
285284
@overload
286-
def gather( # type: ignore[misc]
285+
def gather( # type: ignore[overload-overlap]
287286
__coro_or_future1: _FutureLike[_T1],
288287
__coro_or_future2: _FutureLike[_T2],
289288
__coro_or_future3: _FutureLike[_T3],
@@ -293,7 +292,7 @@ else:
293292
return_exceptions: bool,
294293
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
295294
@overload
296-
def gather( # type: ignore[misc]
295+
def gather( # type: ignore[overload-overlap]
297296
__coro_or_future1: _FutureLike[_T1],
298297
__coro_or_future2: _FutureLike[_T2],
299298
__coro_or_future3: _FutureLike[_T3],
@@ -314,7 +313,7 @@ else:
314313
]
315314
]: ...
316315
@overload
317-
def gather( # type: ignore[misc]
316+
def gather(
318317
*coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: bool
319318
) -> Future[list[_T | BaseException]]: ...
320319

@@ -338,23 +337,27 @@ else:
338337

339338
if sys.version_info >= (3, 11):
340339
@overload
341-
async def wait(fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED") -> tuple[set[_FT], set[_FT]]: ... # type: ignore[misc]
340+
async def wait(
341+
fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
342+
) -> tuple[set[_FT], set[_FT]]: ...
342343
@overload
343344
async def wait(
344345
fs: Iterable[Task[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
345346
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
346347

347348
elif sys.version_info >= (3, 10):
348349
@overload
349-
async def wait(fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED") -> tuple[set[_FT], set[_FT]]: ... # type: ignore[misc]
350+
async def wait( # type: ignore[overload-overlap]
351+
fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
352+
) -> tuple[set[_FT], set[_FT]]: ...
350353
@overload
351354
async def wait(
352355
fs: Iterable[Awaitable[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
353356
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
354357

355358
else:
356359
@overload
357-
async def wait( # type: ignore[misc]
360+
async def wait( # type: ignore[overload-overlap]
358361
fs: Iterable[_FT],
359362
*,
360363
loop: AbstractEventLoop | None = None,

stdlib/builtins.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,11 +1795,11 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
17951795
# Instead, we special-case the most common examples of this: bool and literal integers.
17961796
if sys.version_info >= (3, 8):
17971797
@overload
1798-
def sum(__iterable: Iterable[bool | _LiteralInteger], start: int = 0) -> int: ... # type: ignore[misc]
1798+
def sum(__iterable: Iterable[bool | _LiteralInteger], start: int = 0) -> int: ... # type: ignore[overload-overlap]
17991799

18001800
else:
18011801
@overload
1802-
def sum(__iterable: Iterable[bool | _LiteralInteger], __start: int = 0) -> int: ... # type: ignore[misc]
1802+
def sum(__iterable: Iterable[bool | _LiteralInteger], __start: int = 0) -> int: ... # type: ignore[overload-overlap]
18031803

18041804
@overload
18051805
def sum(__iterable: Iterable[_SupportsSumNoDefaultT]) -> _SupportsSumNoDefaultT | Literal[0]: ...
@@ -1816,7 +1816,7 @@ else:
18161816
# (A "SupportsDunderDict" protocol doesn't work)
18171817
# Use a type: ignore to make complaints about overlapping overloads go away
18181818
@overload
1819-
def vars(__object: type) -> types.MappingProxyType[str, Any]: ... # type: ignore[misc]
1819+
def vars(__object: type) -> types.MappingProxyType[str, Any]: ... # type: ignore[overload-overlap]
18201820
@overload
18211821
def vars(__object: Any = ...) -> dict[str, Any]: ...
18221822

stdlib/collections/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ class UserDict(MutableMapping[_KT, _VT]):
8787
def __or__(self, other: UserDict[_KT, _VT] | dict[_KT, _VT]) -> Self: ...
8888
@overload
8989
def __or__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ...
90-
@overload # type: ignore[misc]
90+
@overload
9191
def __ror__(self, other: UserDict[_KT, _VT] | dict[_KT, _VT]) -> Self: ...
92-
@overload # type: ignore[misc]
92+
@overload
9393
def __ror__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ...
9494
# UserDict.__ior__ should be kept roughly in line with MutableMapping.update()
9595
@overload # type: ignore[misc]

stdlib/contextvars.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def copy_context() -> Context: ...
5050
class Context(Mapping[ContextVar[Any], Any]):
5151
def __init__(self) -> None: ...
5252
@overload
53-
def get(self, __key: ContextVar[_T], __default: None = None) -> _T | None: ... # type: ignore[misc] # overlapping overloads
53+
def get(self, __key: ContextVar[_T], __default: None = None) -> _T | None: ...
5454
@overload
5555
def get(self, __key: ContextVar[_T], __default: _T) -> _T: ...
5656
@overload

stdlib/importlib/metadata/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ if sys.version_info >= (3, 12):
207207

208208
elif sys.version_info >= (3, 10):
209209
@overload
210-
def entry_points() -> SelectableGroups: ... # type: ignore[misc]
210+
def entry_points() -> SelectableGroups: ... # type: ignore[overload-overlap]
211211
@overload
212212
def entry_points(
213213
*, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ...

stdlib/io.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class BufferedIOBase(IOBase):
9494

9595
class FileIO(RawIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
9696
mode: str
97-
name: FileDescriptorOrPath # type: ignore[assignment]
97+
name: FileDescriptorOrPath
9898
def __init__(
9999
self, file: FileDescriptorOrPath, mode: str = ..., closefd: bool = ..., opener: _Opener | None = ...
100100
) -> None: ...

stdlib/math.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def pow(__x: _SupportsFloatOrIndex, __y: _SupportsFloatOrIndex) -> float: ...
125125

126126
if sys.version_info >= (3, 8):
127127
@overload
128-
def prod(__iterable: Iterable[SupportsIndex], *, start: SupportsIndex = 1) -> int: ... # type: ignore[misc]
128+
def prod(__iterable: Iterable[SupportsIndex], *, start: SupportsIndex = 1) -> int: ... # type: ignore[overload-overlap]
129129
@overload
130130
def prod(__iterable: Iterable[_SupportsFloatOrIndex], *, start: _SupportsFloatOrIndex = 1) -> float: ...
131131

stdlib/os/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]):
248248
unsetenv: Callable[[AnyStr, AnyStr], object],
249249
) -> None: ...
250250

251-
def setdefault(self, key: AnyStr, value: AnyStr) -> AnyStr: ... # type: ignore[override]
251+
def setdefault(self, key: AnyStr, value: AnyStr) -> AnyStr: ...
252252
def copy(self) -> dict[AnyStr, AnyStr]: ...
253253
def __delitem__(self, key: AnyStr) -> None: ...
254254
def __getitem__(self, key: AnyStr) -> AnyStr: ...

0 commit comments

Comments
 (0)