Skip to content

Commit c70d303

Browse files
authored
Audit stdlib object annotations (#9519)
1 parent 3d6b8dc commit c70d303

31 files changed

+79
-79
lines changed

stdlib/ast.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import os
22
import sys
33
from _ast import *
4-
from _typeshed import ReadableBuffer
4+
from _typeshed import ReadableBuffer, Unused
55
from collections.abc import Iterator
66
from typing import Any, TypeVar, overload
77
from typing_extensions import Literal
88

99
if sys.version_info >= (3, 8):
1010
class _ABC(type):
1111
if sys.version_info >= (3, 9):
12-
def __init__(cls, *args: object) -> None: ...
12+
def __init__(cls, *args: Unused) -> None: ...
1313

1414
class Num(Constant, metaclass=_ABC):
1515
value: int | float | complex

stdlib/asyncio/events.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ssl
22
import sys
3-
from _typeshed import FileDescriptorLike, ReadableBuffer, Self, StrPath, WriteableBuffer
3+
from _typeshed import FileDescriptorLike, ReadableBuffer, Self, StrPath, Unused, WriteableBuffer
44
from abc import ABCMeta, abstractmethod
55
from collections.abc import Awaitable, Callable, Coroutine, Generator, Sequence
66
from contextvars import Context
@@ -96,7 +96,7 @@ class AbstractServer:
9696
@abstractmethod
9797
def close(self) -> None: ...
9898
async def __aenter__(self: Self) -> Self: ...
99-
async def __aexit__(self, *exc: object) -> None: ...
99+
async def __aexit__(self, *exc: Unused) -> None: ...
100100
@abstractmethod
101101
def get_loop(self) -> AbstractEventLoop: ...
102102
@abstractmethod

stdlib/asyncio/locks.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import enum
22
import sys
3-
from _typeshed import Self
3+
from _typeshed import Self, Unused
44
from collections import deque
55
from collections.abc import Callable, Generator
66
from types import TracebackType
@@ -31,7 +31,7 @@ else:
3131
class _ContextManager:
3232
def __init__(self, lock: Lock | Semaphore) -> None: ...
3333
def __enter__(self) -> None: ...
34-
def __exit__(self, *args: object) -> None: ...
34+
def __exit__(self, *args: Unused) -> None: ...
3535

3636
class _ContextManagerMixin:
3737
# Apparently this exists to *prohibit* use as a context manager.
@@ -104,7 +104,7 @@ if sys.version_info >= (3, 11):
104104
class Barrier(_LoopBoundMixin):
105105
def __init__(self, parties: int) -> None: ...
106106
async def __aenter__(self: Self) -> Self: ...
107-
async def __aexit__(self, *args: object) -> None: ...
107+
async def __aexit__(self, *args: Unused) -> None: ...
108108
async def wait(self) -> int: ...
109109
async def abort(self) -> None: ...
110110
async def reset(self) -> None: ...

stdlib/asyncio/runners.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from _typeshed import Self
2+
from _typeshed import Self, Unused
33
from collections.abc import Callable, Coroutine
44
from contextvars import Context
55
from typing import Any, TypeVar
@@ -18,7 +18,7 @@ if sys.version_info >= (3, 11):
1818
class Runner:
1919
def __init__(self, *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...) -> None: ...
2020
def __enter__(self: Self) -> Self: ...
21-
def __exit__(self, exc_type: object, exc_val: object, exc_tb: object) -> None: ...
21+
def __exit__(self, exc_type: Unused, exc_val: Unused, exc_tb: Unused) -> None: ...
2222
def close(self) -> None: ...
2323
def get_loop(self) -> AbstractEventLoop: ...
2424
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = ...) -> _T: ...

stdlib/builtins.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ class function:
953953

954954
__module__: str
955955
# mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any.
956-
def __get__(self, obj: object | None, type: type | None = ...) -> Any: ...
956+
def __get__(self, obj: object, type: type | None = ...) -> Any: ...
957957

958958
class list(MutableSequence[_T], Generic[_T]):
959959
@overload

stdlib/cProfile.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from _typeshed import Self, StrOrBytesPath
2+
from _typeshed import Self, StrOrBytesPath, Unused
33
from collections.abc import Callable
44
from types import CodeType
55
from typing import Any, TypeVar
@@ -32,6 +32,6 @@ class Profile:
3232
def runcall(self, __func: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> _T: ...
3333
if sys.version_info >= (3, 8):
3434
def __enter__(self: Self) -> Self: ...
35-
def __exit__(self, *exc_info: object) -> None: ...
35+
def __exit__(self, *exc_info: Unused) -> None: ...
3636

3737
def label(code: str | CodeType) -> _Label: ... # undocumented

stdlib/calendar.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import datetime
22
import sys
3+
from _typeshed import Unused
34
from collections.abc import Iterable, Sequence
45
from time import struct_time
56
from typing import ClassVar
@@ -108,7 +109,7 @@ class HTMLCalendar(Calendar):
108109
class different_locale:
109110
def __init__(self, locale: _LocaleType) -> None: ...
110111
def __enter__(self) -> None: ...
111-
def __exit__(self, *args: object) -> None: ...
112+
def __exit__(self, *args: Unused) -> None: ...
112113

113114
class LocaleTextCalendar(TextCalendar):
114115
def __init__(self, firstweekday: int = ..., locale: _LocaleType | None = ...) -> None: ...

stdlib/cgi.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from _typeshed import Self, SupportsGetItem, SupportsItemAccess
2+
from _typeshed import Self, SupportsGetItem, SupportsItemAccess, Unused
33
from builtins import list as _list, type as _type
44
from collections.abc import Iterable, Iterator, Mapping
55
from email.message import Message
@@ -106,7 +106,7 @@ class FieldStorage:
106106
separator: str = ...,
107107
) -> None: ...
108108
def __enter__(self: Self) -> Self: ...
109-
def __exit__(self, *args: object) -> None: ...
109+
def __exit__(self, *args: Unused) -> None: ...
110110
def __iter__(self) -> Iterator[str]: ...
111111
def __getitem__(self, key: str) -> Any: ...
112112
def getvalue(self, key: str, default: Any = ...) -> Any: ...

stdlib/concurrent/futures/_base.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
import threading
3-
from _typeshed import Self
3+
from _typeshed import Self, Unused
44
from collections.abc import Callable, Iterable, Iterator, Sequence
55
from logging import Logger
66
from types import TracebackType
@@ -108,4 +108,4 @@ class _AcquireFutures:
108108
futures: Iterable[Future[Any]]
109109
def __init__(self, futures: Iterable[Future[Any]]) -> None: ...
110110
def __enter__(self) -> None: ...
111-
def __exit__(self, *args: object) -> None: ...
111+
def __exit__(self, *args: Unused) -> None: ...

stdlib/contextlib.pyi

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import abc
22
import sys
3-
from _typeshed import FileDescriptorOrPath, Self
3+
from _typeshed import FileDescriptorOrPath, Self, Unused
44
from abc import abstractmethod
55
from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Generator, Iterator
66
from types import TracebackType
@@ -108,7 +108,7 @@ _SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose)
108108

109109
class closing(AbstractContextManager[_SupportsCloseT]):
110110
def __init__(self, thing: _SupportsCloseT) -> None: ...
111-
def __exit__(self, *exc_info: object) -> None: ...
111+
def __exit__(self, *exc_info: Unused) -> None: ...
112112

113113
if sys.version_info >= (3, 10):
114114
class _SupportsAclose(Protocol):
@@ -117,7 +117,7 @@ if sys.version_info >= (3, 10):
117117

118118
class aclosing(AbstractAsyncContextManager[_SupportsAcloseT]):
119119
def __init__(self, thing: _SupportsAcloseT) -> None: ...
120-
async def __aexit__(self, *exc_info: object) -> None: ...
120+
async def __aexit__(self, *exc_info: Unused) -> None: ...
121121

122122
class suppress(AbstractContextManager[None]):
123123
def __init__(self, *exceptions: type[BaseException]) -> None: ...
@@ -178,9 +178,9 @@ if sys.version_info >= (3, 10):
178178
@overload
179179
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ...
180180
def __enter__(self) -> _T: ...
181-
def __exit__(self, *exctype: object) -> None: ...
181+
def __exit__(self, *exctype: Unused) -> None: ...
182182
async def __aenter__(self) -> _T: ...
183-
async def __aexit__(self, *exctype: object) -> None: ...
183+
async def __aexit__(self, *exctype: Unused) -> None: ...
184184

185185
else:
186186
class nullcontext(AbstractContextManager[_T]):
@@ -190,7 +190,7 @@ else:
190190
@overload
191191
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ...
192192
def __enter__(self) -> _T: ...
193-
def __exit__(self, *exctype: object) -> None: ...
193+
def __exit__(self, *exctype: Unused) -> None: ...
194194

195195
if sys.version_info >= (3, 11):
196196
_T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=FileDescriptorOrPath)
@@ -199,4 +199,4 @@ if sys.version_info >= (3, 11):
199199
path: _T_fd_or_any_path
200200
def __init__(self, path: _T_fd_or_any_path) -> None: ...
201201
def __enter__(self) -> None: ...
202-
def __exit__(self, *excinfo: object) -> None: ...
202+
def __exit__(self, *excinfo: Unused) -> None: ...

stdlib/distutils/util.pyi

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import StrPath
1+
from _typeshed import StrPath, Unused
22
from collections.abc import Callable, Container, Iterable, Mapping
33
from typing import Any
44
from typing_extensions import Literal
@@ -25,10 +25,7 @@ def byte_compile(
2525
) -> None: ...
2626
def rfc822_escape(header: str) -> str: ...
2727
def run_2to3(
28-
files: Iterable[str],
29-
fixer_names: Iterable[str] | None = ...,
30-
options: Mapping[str, Any] | None = ...,
31-
explicit: Container[str] | None = ..., # unused
28+
files: Iterable[str], fixer_names: Iterable[str] | None = ..., options: Mapping[str, Any] | None = ..., explicit: Unused = ...
3229
) -> None: ...
3330
def copydir_run_2to3(
3431
src: StrPath,

stdlib/enum.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
import types
3-
from _typeshed import Self, SupportsKeysAndGetItem
3+
from _typeshed import Self, SupportsKeysAndGetItem, Unused
44
from abc import ABCMeta
55
from builtins import property as _builtins_property
66
from collections.abc import Iterable, Iterator, Mapping
@@ -177,7 +177,7 @@ class Enum(metaclass=EnumMeta):
177177
def __new__(cls: type[Self], value: object) -> Self: ...
178178
def __dir__(self) -> list[str]: ...
179179
def __format__(self, format_spec: str) -> str: ...
180-
def __reduce_ex__(self, proto: object) -> tuple[Any, ...]: ...
180+
def __reduce_ex__(self, proto: Unused) -> tuple[Any, ...]: ...
181181

182182
if sys.version_info >= (3, 11):
183183
class ReprEnum(Enum): ...

stdlib/mmap.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from _typeshed import ReadableBuffer, Self
2+
from _typeshed import ReadableBuffer, Self, Unused
33
from collections.abc import Iterable, Iterator, Sized
44
from typing import NoReturn, overload
55

@@ -74,7 +74,7 @@ class mmap(Iterable[int], Sized):
7474
# so we claim that there is also an __iter__ to help type checkers.
7575
def __iter__(self) -> Iterator[int]: ...
7676
def __enter__(self: Self) -> Self: ...
77-
def __exit__(self, *args: object) -> None: ...
77+
def __exit__(self, *args: Unused) -> None: ...
7878

7979
if sys.version_info >= (3, 8) and sys.platform != "win32":
8080
MADV_NORMAL: int

stdlib/multiprocessing/forkserver.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import FileDescriptorLike
1+
from _typeshed import FileDescriptorLike, Unused
22
from collections.abc import Sequence
33
from struct import Struct
44
from typing import Any
@@ -19,7 +19,7 @@ def main(
1919
alive_r: FileDescriptorLike,
2020
preload: Sequence[str],
2121
main_path: str | None = ...,
22-
sys_path: object | None = ...,
22+
sys_path: Unused = ...,
2323
) -> None: ...
2424
def read_signed(fd: int) -> Any: ...
2525
def write_signed(fd: int, n: int) -> None: ...

stdlib/multiprocessing/reduction.pyi

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pickle
22
import sys
3-
from _typeshed import HasFileno, SupportsWrite
3+
from _typeshed import HasFileno, SupportsWrite, Unused
44
from abc import ABCMeta
55
from builtins import type as Type # alias to avoid name clash
66
from collections.abc import Callable
@@ -54,8 +54,7 @@ else:
5454
ACKNOWLEDGE: Literal[False]
5555

5656
def recvfds(sock: socket, size: int) -> list[int]: ...
57-
# destination_pid is unused
58-
def send_handle(conn: HasFileno, handle: int, destination_pid: object) -> None: ...
57+
def send_handle(conn: HasFileno, handle: int, destination_pid: Unused) -> None: ...
5958
def recv_handle(conn: HasFileno) -> int: ...
6059
def sendfds(sock: socket, fds: list[int]) -> None: ...
6160
def DupFd(fd: int) -> Any: ... # Return type is really hard to get right
@@ -92,5 +91,4 @@ class AbstractReducer(metaclass=ABCMeta):
9291
sendfds = _sendfds
9392
recvfds = _recvfds
9493
DupFd = _DupFd
95-
# *args are unused
96-
def __init__(self, *args: object) -> None: ...
94+
def __init__(self, *args: Unused) -> None: ...

stdlib/multiprocessing/util.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import threading
2-
from _typeshed import Incomplete, ReadableBuffer, SupportsTrunc
2+
from _typeshed import Incomplete, ReadableBuffer, SupportsTrunc, Unused
33
from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence
44
from logging import Logger, _Level as _LoggingLevel
55
from typing import Any, SupportsInt
@@ -56,7 +56,7 @@ class Finalize:
5656
) -> None: ...
5757
def __call__(
5858
self,
59-
wr: object = ...,
59+
wr: Unused = ...,
6060
_finalizer_registry: MutableMapping[Incomplete, Incomplete] = ...,
6161
sub_debug: Callable[..., object] = ...,
6262
getpid: Callable[[], int] = ...,
@@ -70,7 +70,7 @@ class ForkAwareThreadLock:
7070
acquire: Callable[[bool, float], bool]
7171
release: Callable[[], None]
7272
def __enter__(self) -> bool: ...
73-
def __exit__(self, *args: object) -> None: ...
73+
def __exit__(self, *args: Unused) -> None: ...
7474

7575
class ForkAwareLocal(threading.local): ...
7676

stdlib/nntplib.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import datetime
22
import socket
33
import ssl
44
import sys
5-
from _typeshed import Self
5+
from _typeshed import Self, Unused
66
from builtins import list as _list # conflicts with a method named "list"
77
from collections.abc import Iterable
88
from typing import IO, Any, NamedTuple
@@ -73,7 +73,7 @@ class NNTP:
7373
timeout: float = ...,
7474
) -> None: ...
7575
def __enter__(self: Self) -> Self: ...
76-
def __exit__(self, *args: object) -> None: ...
76+
def __exit__(self, *args: Unused) -> None: ...
7777
def getwelcome(self) -> str: ...
7878
def getcapabilities(self) -> dict[str, _list[str]]: ...
7979
def set_debuglevel(self, level: int) -> None: ...

stdlib/os/__init__.pyi

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ from _typeshed import (
1515
StrOrBytesPath,
1616
StrPath,
1717
SupportsLenAndGetItem,
18+
Unused,
1819
WriteableBuffer,
1920
structseq,
2021
)
@@ -730,7 +731,7 @@ def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ...
730731

731732
class _ScandirIterator(Iterator[DirEntry[AnyStr]], AbstractContextManager[_ScandirIterator[AnyStr]]):
732733
def __next__(self) -> DirEntry[AnyStr]: ...
733-
def __exit__(self, *args: object) -> None: ...
734+
def __exit__(self, *args: Unused) -> None: ...
734735
def close(self) -> None: ...
735736

736737
@overload
@@ -997,7 +998,7 @@ if sys.version_info >= (3, 8):
997998
def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], object]) -> None: ...
998999
def close(self) -> None: ...
9991000
def __enter__(self: Self) -> Self: ...
1000-
def __exit__(self, *args: object) -> None: ...
1001+
def __exit__(self, *args: Unused) -> None: ...
10011002

10021003
def add_dll_directory(path: str) -> _AddedDllDirectory: ...
10031004
if sys.platform == "linux":

stdlib/pydoc.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def replace(text: AnyStr, *pairs: AnyStr) -> AnyStr: ...
2626
def cram(text: str, maxlen: int) -> str: ...
2727
def stripid(text: str) -> str: ...
2828
def allmethods(cl: type) -> MutableMapping[str, MethodType]: ...
29-
def visiblename(name: str, all: Container[str] | None = ..., obj: object | None = ...) -> bool: ...
29+
def visiblename(name: str, all: Container[str] | None = ..., obj: object = ...) -> bool: ...
3030
def classify_class_attrs(object: object) -> list[tuple[str, str, type, str]]: ...
3131
def ispackage(path: str) -> bool: ...
3232
def source_synopsis(file: IO[AnyStr]) -> AnyStr | None: ...

stdlib/runpy.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import Self
1+
from _typeshed import Self, Unused
22
from types import ModuleType
33
from typing import Any
44

@@ -9,13 +9,13 @@ class _TempModule:
99
module: ModuleType
1010
def __init__(self, mod_name: str) -> None: ...
1111
def __enter__(self: Self) -> Self: ...
12-
def __exit__(self, *args: object) -> None: ...
12+
def __exit__(self, *args: Unused) -> None: ...
1313

1414
class _ModifiedArgv0:
1515
value: Any
1616
def __init__(self, value: Any) -> None: ...
1717
def __enter__(self) -> None: ...
18-
def __exit__(self, *args: object) -> None: ...
18+
def __exit__(self, *args: Unused) -> None: ...
1919

2020
def run_module(
2121
mod_name: str, init_globals: dict[str, Any] | None = ..., run_name: str | None = ..., alter_sys: bool = ...

0 commit comments

Comments
 (0)