From 54bf91d8b4775f6cbfeb1c50709a8144cc9dffbf Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 12 Jan 2023 20:55:57 -0500 Subject: [PATCH 1/4] Update Unused and __exit__ parameters in stdlib --- stdlib/ast.pyi | 4 ++-- stdlib/asyncio/events.pyi | 4 ++-- stdlib/asyncio/locks.pyi | 6 +++--- stdlib/asyncio/runners.pyi | 5 ++++- stdlib/cProfile.pyi | 4 ++-- stdlib/calendar.pyi | 3 ++- stdlib/cgi.pyi | 4 ++-- stdlib/concurrent/futures/_base.pyi | 4 ++-- stdlib/contextlib.pyi | 14 +++++++------- stdlib/distutils/util.pyi | 7 ++----- stdlib/enum.pyi | 4 ++-- stdlib/mmap.pyi | 4 ++-- stdlib/multiprocessing/forkserver.pyi | 4 ++-- stdlib/multiprocessing/reduction.pyi | 8 +++----- stdlib/multiprocessing/util.pyi | 6 +++--- stdlib/nntplib.pyi | 4 ++-- stdlib/os/__init__.pyi | 5 +++-- stdlib/runpy.pyi | 6 +++--- stdlib/selectors.pyi | 4 ++-- stdlib/socket.pyi | 7 +++---- stdlib/sqlite3/dbapi2.pyi | 12 +++++++----- stdlib/sunau.pyi | 6 +++--- stdlib/uuid.pyi | 9 ++++++++- stdlib/wave.pyi | 6 +++--- stdlib/xml/dom/xmlbuilder.pyi | 13 ++++++------- tests/stubtest_allowlists/py37.txt | 1 - tests/stubtest_allowlists/py38.txt | 1 - 27 files changed, 80 insertions(+), 75 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 9a5bf0a623fb..7ff0d69a01d5 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1,7 +1,7 @@ import os import sys from _ast import * -from _typeshed import ReadableBuffer +from _typeshed import ReadableBuffer, Unused from collections.abc import Iterator from typing import Any, TypeVar, overload from typing_extensions import Literal @@ -9,7 +9,7 @@ from typing_extensions import Literal if sys.version_info >= (3, 8): class _ABC(type): if sys.version_info >= (3, 9): - def __init__(cls, *args: object) -> None: ... + def __init__(cls, *args: Unused) -> None: ... class Num(Constant, metaclass=_ABC): value: int | float | complex diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 7241d5a29f8d..727d4fb18e17 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -1,6 +1,6 @@ import ssl import sys -from _typeshed import FileDescriptorLike, ReadableBuffer, Self, StrPath, WriteableBuffer +from _typeshed import FileDescriptorLike, ReadableBuffer, Self, StrPath, Unused, WriteableBuffer from abc import ABCMeta, abstractmethod from collections.abc import Awaitable, Callable, Coroutine, Generator, Sequence from contextvars import Context @@ -96,7 +96,7 @@ class AbstractServer: @abstractmethod def close(self) -> None: ... async def __aenter__(self: Self) -> Self: ... - async def __aexit__(self, *exc: object) -> None: ... + async def __aexit__(self, *exc: Unused) -> None: ... # noqa: Y036 @abstractmethod def get_loop(self) -> AbstractEventLoop: ... @abstractmethod diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index a5cdf9aa1184..8f04fa3b9696 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -1,6 +1,6 @@ import enum import sys -from _typeshed import Self +from _typeshed import Self, Unused from collections import deque from collections.abc import Callable, Generator from types import TracebackType @@ -31,7 +31,7 @@ else: class _ContextManager: def __init__(self, lock: Lock | Semaphore) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 class _ContextManagerMixin: # Apparently this exists to *prohibit* use as a context manager. @@ -104,7 +104,7 @@ if sys.version_info >= (3, 11): class Barrier(_LoopBoundMixin): def __init__(self, parties: int) -> None: ... async def __aenter__(self: Self) -> Self: ... - async def __aexit__(self, *args: object) -> None: ... + async def __aexit__(self, *args: Unused) -> None: ... # noqa: Y036 async def wait(self) -> int: ... async def abort(self) -> None: ... async def reset(self) -> None: ... diff --git a/stdlib/asyncio/runners.pyi b/stdlib/asyncio/runners.pyi index 74ed83ed8dc4..0e3621b37852 100644 --- a/stdlib/asyncio/runners.pyi +++ b/stdlib/asyncio/runners.pyi @@ -2,6 +2,7 @@ import sys from _typeshed import Self from collections.abc import Callable, Coroutine from contextvars import Context +from types import TracebackType from typing import Any, TypeVar from typing_extensions import final @@ -18,7 +19,9 @@ if sys.version_info >= (3, 11): class Runner: def __init__(self, *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, exc_type: object, exc_val: object, exc_tb: object) -> None: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... def close(self) -> None: ... def get_loop(self) -> AbstractEventLoop: ... def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = ...) -> _T: ... diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index 6e21fc92ade5..d16518ac0529 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import Self, StrOrBytesPath +from _typeshed import Self, StrOrBytesPath, Unused from collections.abc import Callable from types import CodeType from typing import Any, TypeVar @@ -32,6 +32,6 @@ class Profile: def runcall(self, __func: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> _T: ... if sys.version_info >= (3, 8): def __enter__(self: Self) -> Self: ... - def __exit__(self, *exc_info: object) -> None: ... + def __exit__(self, *exc_info: Unused) -> None: ... # noqa: Y036 def label(code: str | CodeType) -> _Label: ... # undocumented diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 74b8d39caf79..76df5b7cf60c 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -1,5 +1,6 @@ import datetime import sys +from _typeshed import Unused from collections.abc import Iterable, Sequence from time import struct_time from typing import ClassVar @@ -108,7 +109,7 @@ class HTMLCalendar(Calendar): class different_locale: def __init__(self, locale: _LocaleType) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 class LocaleTextCalendar(TextCalendar): def __init__(self, firstweekday: int = ..., locale: _LocaleType | None = ...) -> None: ... diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index ce9a15415aab..c6f909bbc264 100644 --- a/stdlib/cgi.pyi +++ b/stdlib/cgi.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import Self, SupportsGetItem, SupportsItemAccess +from _typeshed import Self, SupportsGetItem, SupportsItemAccess, Unused from builtins import list as _list, type as _type from collections.abc import Iterable, Iterator, Mapping from email.message import Message @@ -106,7 +106,7 @@ class FieldStorage: separator: str = ..., ) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def __iter__(self) -> Iterator[str]: ... def __getitem__(self, key: str) -> Any: ... def getvalue(self, key: str, default: Any = ...) -> Any: ... diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index 3db968878498..fedb45ad12b2 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -1,6 +1,6 @@ import sys import threading -from _typeshed import Self +from _typeshed import Self, Unused from collections.abc import Callable, Iterable, Iterator, Sequence from logging import Logger from types import TracebackType @@ -108,4 +108,4 @@ class _AcquireFutures: futures: Iterable[Future[Any]] def __init__(self, futures: Iterable[Future[Any]]) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 1a6642b643e3..81b32b6bec15 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -1,6 +1,6 @@ import abc import sys -from _typeshed import FileDescriptorOrPath, Self +from _typeshed import FileDescriptorOrPath, Self, Unused from abc import abstractmethod from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Generator, Iterator from types import TracebackType @@ -108,7 +108,7 @@ _SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose) class closing(AbstractContextManager[_SupportsCloseT]): def __init__(self, thing: _SupportsCloseT) -> None: ... - def __exit__(self, *exc_info: object) -> None: ... + def __exit__(self, *exc_info: Unused) -> None: ... # noqa: Y036 if sys.version_info >= (3, 10): class _SupportsAclose(Protocol): @@ -117,7 +117,7 @@ if sys.version_info >= (3, 10): class aclosing(AbstractAsyncContextManager[_SupportsAcloseT]): def __init__(self, thing: _SupportsAcloseT) -> None: ... - async def __aexit__(self, *exc_info: object) -> None: ... + async def __aexit__(self, *exc_info: Unused) -> None: ... # noqa: Y036 class suppress(AbstractContextManager[None]): def __init__(self, *exceptions: type[BaseException]) -> None: ... @@ -178,9 +178,9 @@ if sys.version_info >= (3, 10): @overload def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... def __enter__(self) -> _T: ... - def __exit__(self, *exctype: object) -> None: ... + def __exit__(self, *exctype: Unused) -> None: ... # noqa: Y036 async def __aenter__(self) -> _T: ... - async def __aexit__(self, *exctype: object) -> None: ... + async def __aexit__(self, *exctype: Unused) -> None: ... # noqa: Y036 else: class nullcontext(AbstractContextManager[_T]): @@ -190,7 +190,7 @@ else: @overload def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... def __enter__(self) -> _T: ... - def __exit__(self, *exctype: object) -> None: ... + def __exit__(self, *exctype: Unused) -> None: ... # noqa: Y036 if sys.version_info >= (3, 11): _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=FileDescriptorOrPath) @@ -199,4 +199,4 @@ if sys.version_info >= (3, 11): path: _T_fd_or_any_path def __init__(self, path: _T_fd_or_any_path) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *excinfo: object) -> None: ... + def __exit__(self, *excinfo: Unused) -> None: ... # noqa: Y036 diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index da8d66063536..06f8eff75487 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -1,4 +1,4 @@ -from _typeshed import StrPath +from _typeshed import StrPath, Unused from collections.abc import Callable, Container, Iterable, Mapping from typing import Any from typing_extensions import Literal @@ -25,10 +25,7 @@ def byte_compile( ) -> None: ... def rfc822_escape(header: str) -> str: ... def run_2to3( - files: Iterable[str], - fixer_names: Iterable[str] | None = ..., - options: Mapping[str, Any] | None = ..., - explicit: Container[str] | None = ..., # unused + files: Iterable[str], fixer_names: Iterable[str] | None = ..., options: Mapping[str, Any] | None = ..., explicit: Unused = ... ) -> None: ... def copydir_run_2to3( src: StrPath, diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index a14744f1ba8d..93cd0b3ad052 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -1,6 +1,6 @@ import sys import types -from _typeshed import Self, SupportsKeysAndGetItem +from _typeshed import Self, SupportsKeysAndGetItem, Unused from abc import ABCMeta from builtins import property as _builtins_property from collections.abc import Iterable, Iterator, Mapping @@ -177,7 +177,7 @@ class Enum(metaclass=EnumMeta): def __new__(cls: type[Self], value: object) -> Self: ... def __dir__(self) -> list[str]: ... def __format__(self, format_spec: str) -> str: ... - def __reduce_ex__(self, proto: object) -> tuple[Any, ...]: ... + def __reduce_ex__(self, proto: Unused) -> tuple[Any, ...]: ... if sys.version_info >= (3, 11): class ReprEnum(Enum): ... diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 30084b85bc51..22fb2a6d9654 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import ReadableBuffer, Self +from _typeshed import ReadableBuffer, Self, Unused from collections.abc import Iterable, Iterator, Sized from typing import NoReturn, overload @@ -74,7 +74,7 @@ class mmap(Iterable[int], Sized): # so we claim that there is also an __iter__ to help type checkers. def __iter__(self) -> Iterator[int]: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 if sys.version_info >= (3, 8) and sys.platform != "win32": MADV_NORMAL: int diff --git a/stdlib/multiprocessing/forkserver.pyi b/stdlib/multiprocessing/forkserver.pyi index 10269dfbba29..19f75722df41 100644 --- a/stdlib/multiprocessing/forkserver.pyi +++ b/stdlib/multiprocessing/forkserver.pyi @@ -1,4 +1,4 @@ -from _typeshed import FileDescriptorLike +from _typeshed import FileDescriptorLike, Unused from collections.abc import Sequence from struct import Struct from typing import Any @@ -19,7 +19,7 @@ def main( alive_r: FileDescriptorLike, preload: Sequence[str], main_path: str | None = ..., - sys_path: object | None = ..., + sys_path: Unused = ..., ) -> None: ... def read_signed(fd: int) -> Any: ... def write_signed(fd: int, n: int) -> None: ... diff --git a/stdlib/multiprocessing/reduction.pyi b/stdlib/multiprocessing/reduction.pyi index d6b70aefa48d..86ff2a0db110 100644 --- a/stdlib/multiprocessing/reduction.pyi +++ b/stdlib/multiprocessing/reduction.pyi @@ -1,6 +1,6 @@ import pickle import sys -from _typeshed import HasFileno, SupportsWrite +from _typeshed import HasFileno, SupportsWrite, Unused from abc import ABCMeta from builtins import type as Type # alias to avoid name clash from collections.abc import Callable @@ -54,8 +54,7 @@ else: ACKNOWLEDGE: Literal[False] def recvfds(sock: socket, size: int) -> list[int]: ... - # destination_pid is unused - def send_handle(conn: HasFileno, handle: int, destination_pid: object) -> None: ... + def send_handle(conn: HasFileno, handle: int, destination_pid: Unused) -> None: ... def recv_handle(conn: HasFileno) -> int: ... def sendfds(sock: socket, fds: list[int]) -> None: ... def DupFd(fd: int) -> Any: ... # Return type is really hard to get right @@ -92,5 +91,4 @@ class AbstractReducer(metaclass=ABCMeta): sendfds = _sendfds recvfds = _recvfds DupFd = _DupFd - # *args are unused - def __init__(self, *args: object) -> None: ... + def __init__(self, *args: Unused) -> None: ... diff --git a/stdlib/multiprocessing/util.pyi b/stdlib/multiprocessing/util.pyi index 263781da9432..2485e78bac29 100644 --- a/stdlib/multiprocessing/util.pyi +++ b/stdlib/multiprocessing/util.pyi @@ -1,5 +1,5 @@ import threading -from _typeshed import Incomplete, ReadableBuffer, SupportsTrunc +from _typeshed import Incomplete, ReadableBuffer, SupportsTrunc, Unused from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence from logging import Logger, _Level as _LoggingLevel from typing import Any, SupportsInt @@ -56,7 +56,7 @@ class Finalize: ) -> None: ... def __call__( self, - wr: object = ..., + wr: Unused = ..., _finalizer_registry: MutableMapping[Incomplete, Incomplete] = ..., sub_debug: Callable[..., object] = ..., getpid: Callable[[], int] = ..., @@ -70,7 +70,7 @@ class ForkAwareThreadLock: acquire: Callable[[bool, float], bool] release: Callable[[], None] def __enter__(self) -> bool: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 class ForkAwareLocal(threading.local): ... diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index aa5bcba5726c..10b144ebfec9 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -2,7 +2,7 @@ import datetime import socket import ssl import sys -from _typeshed import Self +from _typeshed import Self, Unused from builtins import list as _list # conflicts with a method named "list" from collections.abc import Iterable from typing import IO, Any, NamedTuple @@ -73,7 +73,7 @@ class NNTP: timeout: float = ..., ) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def getwelcome(self) -> str: ... def getcapabilities(self) -> dict[str, _list[str]]: ... def set_debuglevel(self, level: int) -> None: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index ec31cc5e2a76..5f065ab5728f 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -15,6 +15,7 @@ from _typeshed import ( StrOrBytesPath, StrPath, SupportsLenAndGetItem, + Unused, WriteableBuffer, structseq, ) @@ -730,7 +731,7 @@ def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... class _ScandirIterator(Iterator[DirEntry[AnyStr]], AbstractContextManager[_ScandirIterator[AnyStr]]): def __next__(self) -> DirEntry[AnyStr]: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def close(self) -> None: ... @overload @@ -997,7 +998,7 @@ if sys.version_info >= (3, 8): def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], object]) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def add_dll_directory(path: str) -> _AddedDllDirectory: ... if sys.platform == "linux": diff --git a/stdlib/runpy.pyi b/stdlib/runpy.pyi index 256f8dab14e9..4a20bae33760 100644 --- a/stdlib/runpy.pyi +++ b/stdlib/runpy.pyi @@ -1,4 +1,4 @@ -from _typeshed import Self +from _typeshed import Self, Unused from types import ModuleType from typing import Any @@ -9,13 +9,13 @@ class _TempModule: module: ModuleType def __init__(self, mod_name: str) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 class _ModifiedArgv0: value: Any def __init__(self, value: Any) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def run_module( mod_name: str, init_globals: dict[str, Any] | None = ..., run_name: str | None = ..., alter_sys: bool = ... diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index 95dfaa41a5c0..b1cc502c42a5 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import FileDescriptor, FileDescriptorLike, Self +from _typeshed import FileDescriptor, FileDescriptorLike, Self, Unused from abc import ABCMeta, abstractmethod from collections.abc import Mapping from typing import Any, NamedTuple @@ -29,7 +29,7 @@ class BaseSelector(metaclass=ABCMeta): @abstractmethod def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 class SelectSelector(BaseSelector): def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 678bdafb25f0..0a723c513e93 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -112,7 +112,7 @@ from _socket import ( setdefaulttimeout as setdefaulttimeout, timeout as timeout, ) -from _typeshed import ReadableBuffer, Self, WriteableBuffer +from _typeshed import ReadableBuffer, Self, Unused, WriteableBuffer from collections.abc import Iterable from enum import IntEnum, IntFlag from io import BufferedReader, BufferedRWPair, BufferedWriter, IOBase, RawIOBase, TextIOWrapper @@ -658,7 +658,7 @@ class socket(_socket.socket): self, family: AddressFamily | int = ..., type: SocketKind | int = ..., proto: int = ..., fileno: int | None = ... ) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def dup(self: Self) -> Self: ... # noqa: F811 def accept(self) -> tuple[socket, _RetAddress]: ... # Note that the makefile's documented windows-specific behavior is not represented @@ -735,9 +735,8 @@ def fromfd(fd: _FD, family: AddressFamily | int, type: SocketKind | int, proto: if sys.platform != "win32": if sys.version_info >= (3, 9): - # flags and address appear to be unused in send_fds and recv_fds def send_fds( - sock: socket, buffers: Iterable[ReadableBuffer], fds: Iterable[int], flags: int = ..., address: None = ... + sock: socket, buffers: Iterable[ReadableBuffer], fds: Iterable[int], flags: Unused = ..., address: Unused = ... ) -> int: ... def recv_fds(sock: socket, bufsize: int, maxfds: int, flags: int = ...) -> tuple[bytes, list[int], int, Any]: ... diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index efda3b671ed5..bdf0f07435e5 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -1,6 +1,6 @@ import sqlite3 import sys -from _typeshed import Incomplete, ReadableBuffer, Self, StrOrBytesPath, SupportsLenAndGetItem +from _typeshed import Incomplete, ReadableBuffer, Self, StrOrBytesPath, SupportsLenAndGetItem, Unused from collections.abc import Callable, Generator, Iterable, Iterator, Mapping from datetime import date, datetime, time from types import TracebackType @@ -227,7 +227,7 @@ else: if sys.version_info < (3, 8): class Cache: - def __init__(self, *args: Incomplete, **kwargs: object) -> None: ... + def __init__(self, *args: Incomplete, **kwargs: Unused) -> None: ... def display(self, *args: Incomplete, **kwargs: Incomplete) -> None: ... def get(self, *args: Incomplete, **kwargs: Incomplete) -> None: ... @@ -385,8 +385,8 @@ class Cursor(Iterator[Any]): # Returns either a row (as created by the row_factory) or None, but # putting None in the return annotation causes annoying false positives. def fetchone(self) -> Any: ... - def setinputsizes(self, __sizes: object) -> None: ... # does nothing - def setoutputsize(self, __size: object, __column: object = ...) -> None: ... # does nothing + def setinputsizes(self, __sizes: Unused) -> None: ... # does nothing + def setoutputsize(self, __size: Unused, __column: Unused = ...) -> None: ... # does nothing def __iter__(self: Self) -> Self: ... def __next__(self) -> Any: ... @@ -453,6 +453,8 @@ if sys.version_info >= (3, 11): def seek(self, __offset: int, __origin: int = ...) -> None: ... def __len__(self) -> int: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, __typ: object, __val: object, __tb: object) -> Literal[False]: ... + def __exit__( + self, __typ: type[BaseException] | None, __val: BaseException | None, __tb: TracebackType | None + ) -> Literal[False]: ... def __getitem__(self, __item: SupportsIndex | slice) -> int: ... def __setitem__(self, __item: SupportsIndex | slice, __value: int) -> None: ... diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index 5b21cb03d4a3..114405eab8db 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import Self +from _typeshed import Self, Unused from typing import IO, Any, NamedTuple, NoReturn, overload from typing_extensions import Literal, TypeAlias @@ -33,7 +33,7 @@ class _sunau_params(NamedTuple): class Au_read: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def getfp(self) -> IO[bytes] | None: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -53,7 +53,7 @@ class Au_read: class Au_write: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... diff --git a/stdlib/uuid.pyi b/stdlib/uuid.pyi index 3d9b89a0b9f7..bb0b2740529b 100644 --- a/stdlib/uuid.pyi +++ b/stdlib/uuid.pyi @@ -1,3 +1,5 @@ +import sys +from _typeshed import Unused from enum import Enum from typing_extensions import TypeAlias @@ -64,7 +66,12 @@ class UUID: def __gt__(self, other: UUID) -> bool: ... def __ge__(self, other: UUID) -> bool: ... -def getnode() -> int: ... +if sys.version_info >= (3, 9): + def getnode() -> int: ... + +else: + def getnode(*, getters: Unused = ...) -> int: ... # undocumented + def uuid1(node: _Int | None = ..., clock_seq: _Int | None = ...) -> UUID: ... def uuid3(namespace: UUID, name: str) -> UUID: ... def uuid4() -> UUID: ... diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index 853a26a9469e..bf6bd0207609 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import ReadableBuffer, Self +from _typeshed import ReadableBuffer, Self, Unused from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, overload from typing_extensions import Literal, TypeAlias @@ -25,7 +25,7 @@ class _wave_params(NamedTuple): class Wave_read: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def getfp(self) -> BinaryIO | None: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -45,7 +45,7 @@ class Wave_read: class Wave_write: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: object) -> None: ... + def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... diff --git a/stdlib/xml/dom/xmlbuilder.pyi b/stdlib/xml/dom/xmlbuilder.pyi index 341d717e043b..c07e4ba2465e 100644 --- a/stdlib/xml/dom/xmlbuilder.pyi +++ b/stdlib/xml/dom/xmlbuilder.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Unused from typing import Any, NoReturn from typing_extensions import Literal, TypeAlias from urllib.request import OpenerDirector @@ -66,7 +66,7 @@ class DOMBuilder: # `input` and `cnode` argtypes for `parseWithContext` are unknowable # as the function does nothing with them, and always raises an exception. # But `input` is *probably* `DOMInputSource`? - def parseWithContext(self, input: object, cnode: object, action: Literal[1, 2, 3, 4]) -> NoReturn: ... + def parseWithContext(self, input: Unused, cnode: Unused, action: Literal[1, 2, 3, 4]) -> NoReturn: ... class DOMEntityResolver: def resolveEntity(self, publicId: str | None, systemId: str) -> DOMInputSource: ... @@ -86,9 +86,8 @@ class DOMBuilderFilter: FILTER_SKIP: Literal[3] FILTER_INTERRUPT: Literal[4] whatToShow: int - # The argtypes for acceptNode and startContainer appear to be irrelevant. - def acceptNode(self, element: object) -> Literal[1]: ... - def startContainer(self, element: object) -> Literal[1]: ... + def acceptNode(self, element: Unused) -> Literal[1]: ... + def startContainer(self, element: Unused) -> Literal[1]: ... class DocumentLS: async_: bool @@ -97,8 +96,8 @@ class DocumentLS: # so the argtypes of `uri` and `source` are unknowable. # `source` is *probably* `DOMInputSource`? # `uri` is *probably* a str? (see DOMBuilder.parseURI()) - def load(self, uri: object) -> NoReturn: ... - def loadXML(self, source: object) -> NoReturn: ... + def load(self, uri: Unused) -> NoReturn: ... + def loadXML(self, source: Unused) -> NoReturn: ... def saveXML(self, snode: Node | None) -> str: ... class DOMImplementationLS: diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index f7edf5b2cc23..22abbe9939ba 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -47,7 +47,6 @@ typing._SpecialForm.__new__ typing.runtime_checkable uuid.UUID.int uuid.UUID.is_safe -uuid.getnode # undocumented, unused parameter getters that was later removed xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 xml.etree.cElementTree.TreeBuilder.start # bpo-39495 diff --git a/tests/stubtest_allowlists/py38.txt b/tests/stubtest_allowlists/py38.txt index f81bd86488a7..d5912461e63f 100644 --- a/tests/stubtest_allowlists/py38.txt +++ b/tests/stubtest_allowlists/py38.txt @@ -162,7 +162,6 @@ builtins.memoryview.cast # inspect.signature is incorrect about shape being kw- # C signature is broader than what is actually accepted queue.SimpleQueue.__init__ -uuid.getnode # undocumented, unused parameter getters that was later removed types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime # Runtime signature is incorrect (https://github.com/python/cpython/issues/93021) From 41e1893fedff50110eb9ef6ddff32df60e49b3c3 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 16 Jan 2023 15:46:51 -0500 Subject: [PATCH 2/4] remove # noqa: Y036 --- stdlib/asyncio/events.pyi | 2 +- stdlib/asyncio/locks.pyi | 4 ++-- stdlib/cProfile.pyi | 2 +- stdlib/calendar.pyi | 2 +- stdlib/cgi.pyi | 2 +- stdlib/concurrent/futures/_base.pyi | 2 +- stdlib/contextlib.pyi | 12 ++++++------ stdlib/mmap.pyi | 2 +- stdlib/multiprocessing/util.pyi | 2 +- stdlib/nntplib.pyi | 2 +- stdlib/os/__init__.pyi | 4 ++-- stdlib/runpy.pyi | 4 ++-- stdlib/selectors.pyi | 2 +- stdlib/socket.pyi | 2 +- stdlib/sunau.pyi | 4 ++-- stdlib/wave.pyi | 4 ++-- 16 files changed, 26 insertions(+), 26 deletions(-) diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 727d4fb18e17..096da5fe02b3 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -96,7 +96,7 @@ class AbstractServer: @abstractmethod def close(self) -> None: ... async def __aenter__(self: Self) -> Self: ... - async def __aexit__(self, *exc: Unused) -> None: ... # noqa: Y036 + async def __aexit__(self, *exc: Unused) -> None: ... @abstractmethod def get_loop(self) -> AbstractEventLoop: ... @abstractmethod diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 8f04fa3b9696..2efa8ecc0e02 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -31,7 +31,7 @@ else: class _ContextManager: def __init__(self, lock: Lock | Semaphore) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... class _ContextManagerMixin: # Apparently this exists to *prohibit* use as a context manager. @@ -104,7 +104,7 @@ if sys.version_info >= (3, 11): class Barrier(_LoopBoundMixin): def __init__(self, parties: int) -> None: ... async def __aenter__(self: Self) -> Self: ... - async def __aexit__(self, *args: Unused) -> None: ... # noqa: Y036 + async def __aexit__(self, *args: Unused) -> None: ... async def wait(self) -> int: ... async def abort(self) -> None: ... async def reset(self) -> None: ... diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index d16518ac0529..93c288b04a04 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -32,6 +32,6 @@ class Profile: def runcall(self, __func: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs) -> _T: ... if sys.version_info >= (3, 8): def __enter__(self: Self) -> Self: ... - def __exit__(self, *exc_info: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *exc_info: Unused) -> None: ... def label(code: str | CodeType) -> _Label: ... # undocumented diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 76df5b7cf60c..e47aa1b52181 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -109,7 +109,7 @@ class HTMLCalendar(Calendar): class different_locale: def __init__(self, locale: _LocaleType) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... class LocaleTextCalendar(TextCalendar): def __init__(self, firstweekday: int = ..., locale: _LocaleType | None = ...) -> None: ... diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index c6f909bbc264..08b927a1e1c8 100644 --- a/stdlib/cgi.pyi +++ b/stdlib/cgi.pyi @@ -106,7 +106,7 @@ class FieldStorage: separator: str = ..., ) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def __iter__(self) -> Iterator[str]: ... def __getitem__(self, key: str) -> Any: ... def getvalue(self, key: str, default: Any = ...) -> Any: ... diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index fedb45ad12b2..17e299fb0b48 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -108,4 +108,4 @@ class _AcquireFutures: futures: Iterable[Future[Any]] def __init__(self, futures: Iterable[Future[Any]]) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 81b32b6bec15..bc32ce0ffac5 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -108,7 +108,7 @@ _SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose) class closing(AbstractContextManager[_SupportsCloseT]): def __init__(self, thing: _SupportsCloseT) -> None: ... - def __exit__(self, *exc_info: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *exc_info: Unused) -> None: ... if sys.version_info >= (3, 10): class _SupportsAclose(Protocol): @@ -117,7 +117,7 @@ if sys.version_info >= (3, 10): class aclosing(AbstractAsyncContextManager[_SupportsAcloseT]): def __init__(self, thing: _SupportsAcloseT) -> None: ... - async def __aexit__(self, *exc_info: Unused) -> None: ... # noqa: Y036 + async def __aexit__(self, *exc_info: Unused) -> None: ... class suppress(AbstractContextManager[None]): def __init__(self, *exceptions: type[BaseException]) -> None: ... @@ -178,9 +178,9 @@ if sys.version_info >= (3, 10): @overload def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... def __enter__(self) -> _T: ... - def __exit__(self, *exctype: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *exctype: Unused) -> None: ... async def __aenter__(self) -> _T: ... - async def __aexit__(self, *exctype: Unused) -> None: ... # noqa: Y036 + async def __aexit__(self, *exctype: Unused) -> None: ... else: class nullcontext(AbstractContextManager[_T]): @@ -190,7 +190,7 @@ else: @overload def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... def __enter__(self) -> _T: ... - def __exit__(self, *exctype: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *exctype: Unused) -> None: ... if sys.version_info >= (3, 11): _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=FileDescriptorOrPath) @@ -199,4 +199,4 @@ if sys.version_info >= (3, 11): path: _T_fd_or_any_path def __init__(self, path: _T_fd_or_any_path) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *excinfo: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *excinfo: Unused) -> None: ... diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 22fb2a6d9654..273cd0c6f4d4 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -74,7 +74,7 @@ class mmap(Iterable[int], Sized): # so we claim that there is also an __iter__ to help type checkers. def __iter__(self) -> Iterator[int]: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... if sys.version_info >= (3, 8) and sys.platform != "win32": MADV_NORMAL: int diff --git a/stdlib/multiprocessing/util.pyi b/stdlib/multiprocessing/util.pyi index 2485e78bac29..a91e0247084d 100644 --- a/stdlib/multiprocessing/util.pyi +++ b/stdlib/multiprocessing/util.pyi @@ -70,7 +70,7 @@ class ForkAwareThreadLock: acquire: Callable[[bool, float], bool] release: Callable[[], None] def __enter__(self) -> bool: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... class ForkAwareLocal(threading.local): ... diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 10b144ebfec9..8244be149996 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -73,7 +73,7 @@ class NNTP: timeout: float = ..., ) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def getwelcome(self) -> str: ... def getcapabilities(self) -> dict[str, _list[str]]: ... def set_debuglevel(self, level: int) -> None: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 5f065ab5728f..e3caf7d4f533 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -731,7 +731,7 @@ def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... class _ScandirIterator(Iterator[DirEntry[AnyStr]], AbstractContextManager[_ScandirIterator[AnyStr]]): def __next__(self) -> DirEntry[AnyStr]: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def close(self) -> None: ... @overload @@ -998,7 +998,7 @@ if sys.version_info >= (3, 8): def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], object]) -> None: ... def close(self) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def add_dll_directory(path: str) -> _AddedDllDirectory: ... if sys.platform == "linux": diff --git a/stdlib/runpy.pyi b/stdlib/runpy.pyi index 4a20bae33760..0ee9a2de6206 100644 --- a/stdlib/runpy.pyi +++ b/stdlib/runpy.pyi @@ -9,13 +9,13 @@ class _TempModule: module: ModuleType def __init__(self, mod_name: str) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... class _ModifiedArgv0: value: Any def __init__(self, value: Any) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def run_module( mod_name: str, init_globals: dict[str, Any] | None = ..., run_name: str | None = ..., alter_sys: bool = ... diff --git a/stdlib/selectors.pyi b/stdlib/selectors.pyi index b1cc502c42a5..931692ff7b3a 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -29,7 +29,7 @@ class BaseSelector(metaclass=ABCMeta): @abstractmethod def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... class SelectSelector(BaseSelector): def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 0a723c513e93..938f8cd15631 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -658,7 +658,7 @@ class socket(_socket.socket): self, family: AddressFamily | int = ..., type: SocketKind | int = ..., proto: int = ..., fileno: int | None = ... ) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def dup(self: Self) -> Self: ... # noqa: F811 def accept(self) -> tuple[socket, _RetAddress]: ... # Note that the makefile's documented windows-specific behavior is not represented diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index 114405eab8db..bae55f645854 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -33,7 +33,7 @@ class _sunau_params(NamedTuple): class Au_read: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def getfp(self) -> IO[bytes] | None: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -53,7 +53,7 @@ class Au_read: class Au_write: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index bf6bd0207609..69d583a85ad8 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -25,7 +25,7 @@ class _wave_params(NamedTuple): class Wave_read: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def getfp(self) -> BinaryIO | None: ... def rewind(self) -> None: ... def close(self) -> None: ... @@ -45,7 +45,7 @@ class Wave_read: class Wave_write: def __init__(self, f: _File) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__(self, *args: Unused) -> None: ... # noqa: Y036 + def __exit__(self, *args: Unused) -> None: ... def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ... def setsampwidth(self, sampwidth: int) -> None: ... From 57ff67c93da2f1a355f65ca5d1f2cba7d2d99213 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 17 Jan 2023 10:03:07 -0500 Subject: [PATCH 3/4] PR comments --- stdlib/asyncio/runners.pyi | 7 ++----- stdlib/sqlite3/dbapi2.pyi | 4 +--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/stdlib/asyncio/runners.pyi b/stdlib/asyncio/runners.pyi index 0e3621b37852..8a965c516f1d 100644 --- a/stdlib/asyncio/runners.pyi +++ b/stdlib/asyncio/runners.pyi @@ -1,8 +1,7 @@ import sys -from _typeshed import Self +from _typeshed import Self, Unused from collections.abc import Callable, Coroutine from contextvars import Context -from types import TracebackType from typing import Any, TypeVar from typing_extensions import final @@ -19,9 +18,7 @@ if sys.version_info >= (3, 11): class Runner: def __init__(self, *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...) -> None: ... def __enter__(self: Self) -> Self: ... - def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> None: ... + def __exit__(self, exc_type: Unused, exc_val: Unused, exc_tb: Unused) -> None: ... def close(self) -> None: ... def get_loop(self) -> AbstractEventLoop: ... def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = ...) -> _T: ... diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index bdf0f07435e5..e590dfc4a4ef 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -453,8 +453,6 @@ if sys.version_info >= (3, 11): def seek(self, __offset: int, __origin: int = ...) -> None: ... def __len__(self) -> int: ... def __enter__(self: Self) -> Self: ... - def __exit__( - self, __typ: type[BaseException] | None, __val: BaseException | None, __tb: TracebackType | None - ) -> Literal[False]: ... + def __exit__(self, __typ: object, __val: object, __tb: object) -> Literal[False]: ... def __getitem__(self, __item: SupportsIndex | slice) -> int: ... def __setitem__(self, __item: SupportsIndex | slice, __value: int) -> None: ... From 9a589ba55157530ae80a30fe990d754b6a230edc Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 17 Jan 2023 10:24:53 -0500 Subject: [PATCH 4/4] object | None --- stdlib/builtins.pyi | 2 +- stdlib/pydoc.pyi | 2 +- stdlib/sys.pyi | 2 +- stdlib/types.pyi | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 54380769a109..8aeecc3b1739 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -953,7 +953,7 @@ class function: __module__: str # mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any. - def __get__(self, obj: object | None, type: type | None = ...) -> Any: ... + def __get__(self, obj: object, type: type | None = ...) -> Any: ... class list(MutableSequence[_T], Generic[_T]): @overload diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 0dd2739797f9..518d0f434db4 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -26,7 +26,7 @@ def replace(text: AnyStr, *pairs: AnyStr) -> AnyStr: ... def cram(text: str, maxlen: int) -> str: ... def stripid(text: str) -> str: ... def allmethods(cl: type) -> MutableMapping[str, MethodType]: ... -def visiblename(name: str, all: Container[str] | None = ..., obj: object | None = ...) -> bool: ... +def visiblename(name: str, all: Container[str] | None = ..., obj: object = ...) -> bool: ... def classify_class_attrs(object: object) -> list[tuple[str, str, type, str]]: ... def ispackage(path: str) -> bool: ... def source_synopsis(file: IO[AnyStr]) -> AnyStr | None: ... diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index c3747235d628..51ba5139b9d4 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -304,7 +304,7 @@ if sys.version_info >= (3, 8): exc_value: BaseException | None exc_traceback: TracebackType | None err_msg: str | None - object: _object | None + object: _object unraisablehook: Callable[[UnraisableHookArgs], Any] def __unraisablehook__(__unraisable: UnraisableHookArgs) -> Any: ... def addaudithook(hook: Callable[[str, tuple[Any, ...]], Any]) -> None: ... diff --git a/stdlib/types.pyi b/stdlib/types.pyi index c87f0779796b..b2e76407323c 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -413,7 +413,7 @@ class _StaticFunctionType: # By wrapping FunctionType in _StaticFunctionType, we get the right result; # similar to wrapping a function in staticmethod() at runtime to prevent it # being bound as a method. - def __get__(self, obj: object | None, type: type | None) -> FunctionType: ... + def __get__(self, obj: object, type: type | None) -> FunctionType: ... @final class MethodType: