diff --git a/pyproject.toml b/pyproject.toml index 0d84442d1b..cde205b81b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,6 +105,7 @@ allowed-confusables = ["–"] select = [ "A", # flake8-builtins + "ANN", # flake8-annotations "ASYNC", # flake8-async "B", # flake8-bugbear "C4", # flake8-comprehensions @@ -131,6 +132,9 @@ select = [ ] extend-ignore = [ 'A002', # builtin-argument-shadowing + 'ANN101', # missing-type-self + 'ANN102', # missing-type-cls + 'ANN401', # any-type (mypy's `disallow_any_explicit` is better) 'E402', # module-import-not-at-top-of-file (usually OS-specific) 'E501', # line-too-long 'F403', # undefined-local-with-import-star @@ -160,6 +164,8 @@ extend-ignore = [ 'src/trio/_abc.py' = ['A005'] 'src/trio/_socket.py' = ['A005'] 'src/trio/_ssl.py' = ['A005'] +# Don't check annotations in notes-to-self +'notes-to-self/*.py' = ['ANN001', 'ANN002', 'ANN003', 'ANN201', 'ANN202', 'ANN204'] [tool.ruff.lint.isort] combine-as-imports = true diff --git a/src/trio/_channel.py b/src/trio/_channel.py index cb7df95ff6..6410d9120c 100644 --- a/src/trio/_channel.py +++ b/src/trio/_channel.py @@ -99,7 +99,7 @@ def __new__( # type: ignore[misc] # "must return a subtype" ) -> tuple[MemorySendChannel[T], MemoryReceiveChannel[T]]: return _open_memory_channel(max_buffer_size) - def __init__(self, max_buffer_size: int | float): # noqa: PYI041 + def __init__(self, max_buffer_size: int | float) -> None: # noqa: PYI041 ... else: diff --git a/src/trio/_core/_instrumentation.py b/src/trio/_core/_instrumentation.py index bbb2ba2cc8..40bddd1a23 100644 --- a/src/trio/_core/_instrumentation.py +++ b/src/trio/_core/_instrumentation.py @@ -34,7 +34,7 @@ class Instruments(dict[str, dict[Instrument, None]]): __slots__ = () - def __init__(self, incoming: Sequence[Instrument]): + def __init__(self, incoming: Sequence[Instrument]) -> None: self["_all"] = {} for instrument in incoming: self.add_instrument(instrument) diff --git a/src/trio/_core/_mock_clock.py b/src/trio/_core/_mock_clock.py index 70c4e58a2d..7e85df2f7b 100644 --- a/src/trio/_core/_mock_clock.py +++ b/src/trio/_core/_mock_clock.py @@ -63,7 +63,7 @@ class MockClock(Clock): """ - def __init__(self, rate: float = 0.0, autojump_threshold: float = inf): + def __init__(self, rate: float = 0.0, autojump_threshold: float = inf) -> None: # when the real clock said 'real_base', the virtual time was # 'virtual_base', and since then it's advanced at 'rate' virtual # seconds per real second. diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py index 892eb9df60..21bdecd448 100644 --- a/src/trio/_core/_run.py +++ b/src/trio/_core/_run.py @@ -1128,7 +1128,7 @@ def __init__( parent_task: Task, cancel_scope: CancelScope, strict_exception_groups: bool, - ): + ) -> None: self._parent_task = parent_task self._strict_exception_groups = strict_exception_groups parent_task._child_nurseries.append(self) diff --git a/src/trio/_dtls.py b/src/trio/_dtls.py index c8614a8e88..c971471c07 100644 --- a/src/trio/_dtls.py +++ b/src/trio/_dtls.py @@ -665,7 +665,7 @@ def challenge_for( class _Queue(Generic[_T]): - def __init__(self, incoming_packets_buffer: int | float): # noqa: PYI041 + def __init__(self, incoming_packets_buffer: int | float) -> None: # noqa: PYI041 self.s, self.r = trio.open_memory_channel[_T](incoming_packets_buffer) diff --git a/src/trio/_file_io.py b/src/trio/_file_io.py index 677c1b0362..5a612ffb09 100644 --- a/src/trio/_file_io.py +++ b/src/trio/_file_io.py @@ -31,6 +31,8 @@ ) from typing_extensions import Literal + from ._sync import CapacityLimiter + # This list is also in the docs, make sure to keep them in sync _FILE_SYNC_ATTRS: set[str] = { "closed", @@ -241,7 +243,10 @@ def __getattr__(self, name: str) -> object: meth = getattr(self._wrapped, name) @async_wraps(self.__class__, self._wrapped.__class__, name) - async def wrapper(*args, **kwargs): + async def wrapper( + *args: Callable[..., T], + **kwargs: object | str | bool | CapacityLimiter | None, + ) -> T: func = partial(meth, *args, **kwargs) return await trio.to_thread.run_sync(func) diff --git a/src/trio/_highlevel_socket.py b/src/trio/_highlevel_socket.py index 8d9e768074..c04e66e1bf 100644 --- a/src/trio/_highlevel_socket.py +++ b/src/trio/_highlevel_socket.py @@ -68,7 +68,7 @@ class SocketStream(HalfCloseableStream): """ - def __init__(self, socket: SocketType): + def __init__(self, socket: SocketType) -> None: if not isinstance(socket, tsocket.SocketType): raise TypeError("SocketStream requires a Trio socket object") if socket.type != tsocket.SOCK_STREAM: @@ -364,7 +364,7 @@ class SocketListener(Listener[SocketStream]): """ - def __init__(self, socket: SocketType): + def __init__(self, socket: SocketType) -> None: if not isinstance(socket, tsocket.SocketType): raise TypeError("SocketListener requires a Trio socket object") if socket.type != tsocket.SOCK_STREAM: diff --git a/src/trio/_repl.py b/src/trio/_repl.py index 73f050140e..f9efcc0017 100644 --- a/src/trio/_repl.py +++ b/src/trio/_repl.py @@ -22,7 +22,7 @@ class TrioInteractiveConsole(InteractiveConsole): # we make the type more specific on our subclass locals: dict[str, object] - def __init__(self, repl_locals: dict[str, object] | None = None): + def __init__(self, repl_locals: dict[str, object] | None = None) -> None: super().__init__(locals=repl_locals) self.compile.compiler.flags |= ast.PyCF_ALLOW_TOP_LEVEL_AWAIT diff --git a/src/trio/_socket.py b/src/trio/_socket.py index 5835a4d759..ce57aab9c9 100644 --- a/src/trio/_socket.py +++ b/src/trio/_socket.py @@ -66,7 +66,7 @@ class _try_sync: def __init__( self, blocking_exc_override: Callable[[BaseException], bool] | None = None, - ): + ) -> None: self._blocking_exc_override = blocking_exc_override def _is_blocking_io_error(self, exc: BaseException) -> bool: @@ -782,7 +782,7 @@ async def sendmsg( class _SocketType(SocketType): - def __init__(self, sock: _stdlib_socket.socket): + def __init__(self, sock: _stdlib_socket.socket) -> None: if type(sock) is not _stdlib_socket.socket: # For example, ssl.SSLSocket subclasses socket.socket, but we # certainly don't want to blindly wrap one of those. diff --git a/src/trio/_subprocess_platform/__init__.py b/src/trio/_subprocess_platform/__init__.py index d74cd462a0..9a5e4d1da1 100644 --- a/src/trio/_subprocess_platform/__init__.py +++ b/src/trio/_subprocess_platform/__init__.py @@ -85,11 +85,11 @@ def create_pipe_from_child_output() -> tuple[ClosableReceiveStream, int]: elif os.name == "posix": - def create_pipe_to_child_stdin(): + def create_pipe_to_child_stdin() -> tuple[trio.lowlevel.FdStream, int]: rfd, wfd = os.pipe() return trio.lowlevel.FdStream(wfd), rfd - def create_pipe_from_child_output(): + def create_pipe_from_child_output() -> tuple[trio.lowlevel.FdStream, int]: rfd, wfd = os.pipe() return trio.lowlevel.FdStream(rfd), wfd @@ -106,12 +106,12 @@ def create_pipe_from_child_output(): from .._windows_pipes import PipeReceiveStream, PipeSendStream - def create_pipe_to_child_stdin(): + def create_pipe_to_child_stdin() -> tuple[PipeSendStream, int]: # for stdin, we want the write end (our end) to use overlapped I/O rh, wh = windows_pipe(overlapped=(False, True)) return PipeSendStream(wh), msvcrt.open_osfhandle(rh, os.O_RDONLY) - def create_pipe_from_child_output(): + def create_pipe_from_child_output() -> tuple[PipeReceiveStream, int]: # for stdout/err, it's the read end that's overlapped rh, wh = windows_pipe(overlapped=(True, False)) return PipeReceiveStream(rh), msvcrt.open_osfhandle(wh, 0) diff --git a/src/trio/_sync.py b/src/trio/_sync.py index 03d518aab9..ca373922b0 100644 --- a/src/trio/_sync.py +++ b/src/trio/_sync.py @@ -220,7 +220,7 @@ class CapacityLimiter(AsyncContextManagerMixin): """ # total_tokens would ideally be int|Literal[math.inf] - but that's not valid typing - def __init__(self, total_tokens: int | float): # noqa: PYI041 + def __init__(self, total_tokens: int | float) -> None: # noqa: PYI041 self._lot = ParkingLot() self._borrowers: set[Task | object] = set() # Maps tasks attempting to acquire -> borrower, to handle on-behalf-of @@ -433,7 +433,7 @@ class Semaphore(AsyncContextManagerMixin): """ - def __init__(self, initial_value: int, *, max_value: int | None = None): + def __init__(self, initial_value: int, *, max_value: int | None = None) -> None: if not isinstance(initial_value, int): raise TypeError("initial_value must be an int") if initial_value < 0: @@ -759,7 +759,7 @@ class Condition(AsyncContextManagerMixin): """ - def __init__(self, lock: Lock | None = None): + def __init__(self, lock: Lock | None = None) -> None: if lock is None: lock = Lock() if type(lock) is not Lock: diff --git a/src/trio/_tests/test_highlevel_open_tcp_listeners.py b/src/trio/_tests/test_highlevel_open_tcp_listeners.py index 6af3721852..61abd43f02 100644 --- a/src/trio/_tests/test_highlevel_open_tcp_listeners.py +++ b/src/trio/_tests/test_highlevel_open_tcp_listeners.py @@ -197,10 +197,7 @@ def setsockopt( ) -> None: pass - async def bind( - self, - address: AddressFormat, - ) -> None: + async def bind(self, address: AddressFormat) -> None: pass def listen(self, /, backlog: int = min(stdlib_socket.SOMAXCONN, 128)) -> None: diff --git a/src/trio/_tests/test_highlevel_ssl_helpers.py b/src/trio/_tests/test_highlevel_ssl_helpers.py index e32e1957bb..68aa478465 100644 --- a/src/trio/_tests/test_highlevel_ssl_helpers.py +++ b/src/trio/_tests/test_highlevel_ssl_helpers.py @@ -69,7 +69,7 @@ async def getnameinfo( self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int, - ) -> NoReturn: + ) -> NoReturn: # pragma: no cover raise NotImplementedError diff --git a/src/trio/_tests/test_socket.py b/src/trio/_tests/test_socket.py index e09fbc36d7..3f68b285bc 100644 --- a/src/trio/_tests/test_socket.py +++ b/src/trio/_tests/test_socket.py @@ -79,7 +79,7 @@ def _frozenbind( flags: int = 0, ) -> GetAddrInfoArgs: sig = inspect.signature(self._orig_getaddrinfo) - bound = sig.bind(host, port, family, type, proto, flags) + bound = sig.bind(host, port, family=family, type=type, proto=proto, flags=flags) bound.apply_defaults() frozenbound = bound.args assert not bound.kwargs @@ -95,9 +95,16 @@ def set( proto: int = 0, flags: int = 0, ) -> None: - self._responses[self._frozenbind(host, port, family, type, proto, flags)] = ( - response - ) + self._responses[ + self._frozenbind( + host, + port, + family=family, + type=type, + proto=proto, + flags=flags, + ) + ] = response def getaddrinfo( self, diff --git a/src/trio/_tests/test_ssl.py b/src/trio/_tests/test_ssl.py index f96a4feca3..2a16a0cd13 100644 --- a/src/trio/_tests/test_ssl.py +++ b/src/trio/_tests/test_ssl.py @@ -168,8 +168,8 @@ def ssl_echo_serve_sync( # Fixture that gives a raw socket connected to a trio-test-1 echo server # (running in a thread). Useful for testing making connections with different # SSLContexts. -@asynccontextmanager # type: ignore[misc] # decorated contains Any -async def ssl_echo_server_raw(**kwargs: Any) -> AsyncIterator[SocketStream]: +@asynccontextmanager +async def ssl_echo_server_raw(expect_fail: bool = False) -> AsyncIterator[SocketStream]: a, b = stdlib_socket.socketpair() async with trio.open_nursery() as nursery: # Exiting the 'with a, b' context manager closes the sockets, which @@ -178,7 +178,7 @@ async def ssl_echo_server_raw(**kwargs: Any) -> AsyncIterator[SocketStream]: with a, b: nursery.start_soon( trio.to_thread.run_sync, - partial(ssl_echo_serve_sync, b, **kwargs), + partial(ssl_echo_serve_sync, b, expect_fail=expect_fail), ) yield SocketStream(tsocket.from_stdlib_socket(a)) @@ -186,12 +186,12 @@ async def ssl_echo_server_raw(**kwargs: Any) -> AsyncIterator[SocketStream]: # Fixture that gives a properly set up SSLStream connected to a trio-test-1 # echo server (running in a thread) -@asynccontextmanager # type: ignore[misc] # decorated contains Any +@asynccontextmanager async def ssl_echo_server( client_ctx: SSLContext, - **kwargs: Any, + expect_fail: bool = False, ) -> AsyncIterator[SSLStream[Stream]]: - async with ssl_echo_server_raw(**kwargs) as sock: + async with ssl_echo_server_raw(expect_fail=expect_fail) as sock: yield SSLStream(sock, client_ctx, server_hostname="trio-test-1.example.org") @@ -201,7 +201,10 @@ async def ssl_echo_server( # jakkdl: it seems to implement all the abstract methods (now), so I made it inherit # from Stream for the sake of typechecking. class PyOpenSSLEchoStream(Stream): - def __init__(self, sleeper: None = None) -> None: + def __init__( + self, + sleeper: Callable[[str], Awaitable[None]] | None = None, + ) -> None: ctx = SSL.Context(SSL.SSLv23_METHOD) # TLS 1.3 removes renegotiation support. Which is great for them, but # we still have to support versions before that, and that means we @@ -249,6 +252,7 @@ def __init__(self, sleeper: None = None) -> None: "simultaneous calls to PyOpenSSLEchoStream.receive_some", ) + self.sleeper: Callable[[str], Awaitable[None]] if sleeper is None: async def no_op_sleeper(_: object) -> None: @@ -384,12 +388,12 @@ async def do_test( await do_test("receive_some", (1,), "receive_some", (1,)) -@contextmanager # type: ignore[misc] # decorated contains Any +@contextmanager def virtual_ssl_echo_server( client_ctx: SSLContext, - **kwargs: Any, + sleeper: Callable[[str], Awaitable[None]] | None = None, ) -> Iterator[SSLStream[PyOpenSSLEchoStream]]: - fakesock = PyOpenSSLEchoStream(**kwargs) + fakesock = PyOpenSSLEchoStream(sleeper=sleeper) yield SSLStream(fakesock, client_ctx, server_hostname="trio-test-1.example.org") @@ -424,31 +428,43 @@ def ssl_wrap_pair( # type: ignore[misc] MemoryStapledStream: TypeAlias = StapledStream[MemorySendStream, MemoryReceiveStream] -# Explicit "Any" is not allowed -def ssl_memory_stream_pair( # type: ignore[misc] +def ssl_memory_stream_pair( client_ctx: SSLContext, - **kwargs: Any, + client_kwargs: dict[str, str | bytes | bool | None] | None = None, + server_kwargs: dict[str, str | bytes | bool | None] | None = None, ) -> tuple[ SSLStream[MemoryStapledStream], SSLStream[MemoryStapledStream], ]: client_transport, server_transport = memory_stream_pair() - return ssl_wrap_pair(client_ctx, client_transport, server_transport, **kwargs) + return ssl_wrap_pair( + client_ctx, + client_transport, + server_transport, + client_kwargs=client_kwargs, + server_kwargs=server_kwargs, + ) MyStapledStream: TypeAlias = StapledStream[SendStream, ReceiveStream] -# Explicit "Any" is not allowed -def ssl_lockstep_stream_pair( # type: ignore[misc] +def ssl_lockstep_stream_pair( client_ctx: SSLContext, - **kwargs: Any, + client_kwargs: dict[str, str | bytes | bool | None] | None = None, + server_kwargs: dict[str, str | bytes | bool | None] | None = None, ) -> tuple[ SSLStream[MyStapledStream], SSLStream[MyStapledStream], ]: client_transport, server_transport = lockstep_stream_pair() - return ssl_wrap_pair(client_ctx, client_transport, server_transport, **kwargs) + return ssl_wrap_pair( + client_ctx, + client_transport, + server_transport, + client_kwargs=client_kwargs, + server_kwargs=server_kwargs, + ) # Simple smoke test for handshake/send/receive/shutdown talking to a @@ -1327,15 +1343,18 @@ async def test_getpeercert(client_ctx: SSLContext) -> None: async def test_SSLListener(client_ctx: SSLContext) -> None: - # Explicit "Any" is not allowed - async def setup( # type: ignore[misc] - **kwargs: Any, + async def setup( + https_compatible: bool = False, ) -> tuple[tsocket.SocketType, SSLListener[SocketStream], SSLStream[SocketStream]]: listen_sock = tsocket.socket() await listen_sock.bind(("127.0.0.1", 0)) listen_sock.listen(1) socket_listener = SocketListener(listen_sock) - ssl_listener = SSLListener(socket_listener, SERVER_CTX, **kwargs) + ssl_listener = SSLListener( + socket_listener, + SERVER_CTX, + https_compatible=https_compatible, + ) transport_client = await open_tcp_stream(*listen_sock.getsockname()) ssl_client = SSLStream( diff --git a/src/trio/_tests/test_subprocess.py b/src/trio/_tests/test_subprocess.py index e58a40f515..88623a4304 100644 --- a/src/trio/_tests/test_subprocess.py +++ b/src/trio/_tests/test_subprocess.py @@ -88,8 +88,11 @@ def got_signal(proc: Process, sig: SignalType) -> bool: return proc.returncode != 0 -@asynccontextmanager # type: ignore[misc] # Any in decorator -async def open_process_then_kill(*args: Any, **kwargs: Any) -> AsyncIterator[Process]: +@asynccontextmanager # type: ignore[misc] # Any in decorated +async def open_process_then_kill( + *args: Any, + **kwargs: Any, +) -> AsyncIterator[Process]: proc = await open_process(*args, **kwargs) try: yield proc @@ -98,8 +101,11 @@ async def open_process_then_kill(*args: Any, **kwargs: Any) -> AsyncIterator[Pro await proc.wait() -@asynccontextmanager # type: ignore[misc] # Any in decorator -async def run_process_in_nursery(*args: Any, **kwargs: Any) -> AsyncIterator[Process]: +@asynccontextmanager # type: ignore[misc] # Any in decorated +async def run_process_in_nursery( + *args: Any, + **kwargs: Any, +) -> AsyncIterator[Process]: async with _core.open_nursery() as nursery: kwargs.setdefault("check", False) value = await nursery.start(partial(run_process, *args, **kwargs)) diff --git a/src/trio/_tests/test_unix_pipes.py b/src/trio/_tests/test_unix_pipes.py index 6f8fa6e02e..c850ebefea 100644 --- a/src/trio/_tests/test_unix_pipes.py +++ b/src/trio/_tests/test_unix_pipes.py @@ -12,6 +12,9 @@ from .._core._tests.tutil import gc_collect_harder, skip_if_fbsd_pipes_broken from ..testing import check_one_way_stream, wait_all_tasks_blocked +if TYPE_CHECKING: + from .._file_io import _HasFileNo + posix = os.name == "posix" pytestmark = pytest.mark.skipif(not posix, reason="posix only") @@ -30,7 +33,7 @@ async def make_pipe() -> tuple[FdStream, FdStream]: return FdStream(w), FdStream(r) -async def make_clogged_pipe(): +async def make_clogged_pipe() -> tuple[FdStream, FdStream]: s, r = await make_pipe() try: while True: @@ -197,8 +200,11 @@ async def expect_closedresourceerror() -> None: orig_wait_readable = _core._run.TheIOManager.wait_readable - async def patched_wait_readable(*args, **kwargs) -> None: - await orig_wait_readable(*args, **kwargs) + async def patched_wait_readable( + self: _core._run.TheIOManager, + fd: int | _HasFileNo, + ) -> None: + await orig_wait_readable(self, fd) await r.aclose() monkeypatch.setattr(_core._run.TheIOManager, "wait_readable", patched_wait_readable) @@ -225,8 +231,11 @@ async def expect_closedresourceerror() -> None: orig_wait_writable = _core._run.TheIOManager.wait_writable - async def patched_wait_writable(*args, **kwargs) -> None: - await orig_wait_writable(*args, **kwargs) + async def patched_wait_writable( + self: _core._run.TheIOManager, + fd: int | _HasFileNo, + ) -> None: + await orig_wait_writable(self, fd) await s.aclose() monkeypatch.setattr(_core._run.TheIOManager, "wait_writable", patched_wait_writable) diff --git a/src/trio/_tests/test_util.py b/src/trio/_tests/test_util.py index 68f9026e22..23d16fe84c 100644 --- a/src/trio/_tests/test_util.py +++ b/src/trio/_tests/test_util.py @@ -3,8 +3,10 @@ import signal import sys import types -from typing import TYPE_CHECKING, Any, TypeVar +from typing import TYPE_CHECKING, TypeVar +if TYPE_CHECKING: + from collections.abc import AsyncGenerator, Coroutine, Generator import pytest import trio @@ -121,9 +123,11 @@ async def f() -> None: # pragma: no cover import asyncio if sys.version_info < (3, 11): - # not bothering to type this one - @asyncio.coroutine # type: ignore[misc] - def generator_based_coro() -> Any: # pragma: no cover + + @asyncio.coroutine + def generator_based_coro() -> ( + Generator[Coroutine[None, None, None], None, None] + ): # pragma: no cover yield from asyncio.sleep(1) with pytest.raises(TypeError) as excinfo: diff --git a/src/trio/testing/_check_streams.py b/src/trio/testing/_check_streams.py index 3bf5442814..e58e2ddfed 100644 --- a/src/trio/testing/_check_streams.py +++ b/src/trio/testing/_check_streams.py @@ -311,7 +311,7 @@ async def expect_cancelled( # receive stream causes it to wake up. async with _ForceCloseBoth(await stream_maker()) as (s, r): - async def receive_expecting_closed(): + async def receive_expecting_closed() -> None: with _assert_raises(_core.ClosedResourceError): await r.receive_some(10) diff --git a/src/trio/testing/_fake_net.py b/src/trio/testing/_fake_net.py index e5a4b41bb3..6ec7f68b6d 100644 --- a/src/trio/testing/_fake_net.py +++ b/src/trio/testing/_fake_net.py @@ -212,7 +212,7 @@ def __init__( family: AddressFamily, type: SocketKind, proto: int, - ): + ) -> None: self._fake_net = fake_net if not family: # pragma: no cover diff --git a/src/trio/testing/_memory_streams.py b/src/trio/testing/_memory_streams.py index 40e85efaa3..6dd48ebf3d 100644 --- a/src/trio/testing/_memory_streams.py +++ b/src/trio/testing/_memory_streams.py @@ -114,7 +114,7 @@ def __init__( send_all_hook: AsyncHook | None = None, wait_send_all_might_not_block_hook: AsyncHook | None = None, close_hook: SyncHook | None = None, - ): + ) -> None: self._conflict_detector = _util.ConflictDetector( "another task is using this stream", ) @@ -224,7 +224,7 @@ def __init__( self, receive_some_hook: AsyncHook | None = None, close_hook: SyncHook | None = None, - ): + ) -> None: self._conflict_detector = _util.ConflictDetector( "another task is using this stream", ) @@ -550,7 +550,7 @@ async def receive_some(self, max_bytes: int | None = None) -> bytes | bytearray: class _LockstepSendStream(SendStream): - def __init__(self, lbq: _LockstepByteQueue): + def __init__(self, lbq: _LockstepByteQueue) -> None: self._lbq = lbq def close(self) -> None: @@ -568,7 +568,7 @@ async def wait_send_all_might_not_block(self) -> None: class _LockstepReceiveStream(ReceiveStream): - def __init__(self, lbq: _LockstepByteQueue): + def __init__(self, lbq: _LockstepByteQueue) -> None: self._lbq = lbq def close(self) -> None: diff --git a/src/trio/testing/_raises_group.py b/src/trio/testing/_raises_group.py index e93e0bf3bd..717b5f938d 100644 --- a/src/trio/testing/_raises_group.py +++ b/src/trio/testing/_raises_group.py @@ -52,7 +52,7 @@ class _ExceptionInfo(Generic[MatchE]): def __init__( self, excinfo: tuple[type[MatchE], MatchE, types.TracebackType] | None, - ): + ) -> None: self._excinfo = excinfo def fill_unfilled( @@ -174,7 +174,7 @@ def __init__( exception_type: type[MatchE], match: str | Pattern[str] = ..., check: Callable[[MatchE], bool] = ..., - ): ... + ) -> None: ... @overload def __init__( @@ -183,10 +183,10 @@ def __init__( match: str | Pattern[str], # If exception_type is not provided, check() must do any typechecks itself. check: Callable[[BaseException], bool] = ..., - ): ... + ) -> None: ... @overload - def __init__(self, *, check: Callable[[BaseException], bool]): ... + def __init__(self, *, check: Callable[[BaseException], bool]) -> None: ... def __init__( self, @@ -352,7 +352,7 @@ def __init__( flatten_subgroups: bool = False, match: None = None, check: None = None, - ): ... + ) -> None: ... # flatten_subgroups = True also requires no nested RaisesGroup @overload @@ -364,7 +364,7 @@ def __init__( flatten_subgroups: Literal[True], match: str | Pattern[str] | None = None, check: Callable[[BaseExceptionGroup[E]], bool] | None = None, - ): ... + ) -> None: ... @overload def __init__( @@ -375,7 +375,7 @@ def __init__( flatten_subgroups: Literal[False] = False, match: str | Pattern[str] | None = None, check: Callable[[BaseExceptionGroup[E]], bool] | None = None, - ): ... + ) -> None: ... def __init__( self,