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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 7 additions & 7 deletions
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: ...

0 commit comments

Comments
 (0)