From 1194c578197b35ca20ef782f7fa3807e6ca11d40 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 00:55:54 +0000 Subject: [PATCH 1/6] Dependency updates --- .pre-commit-config.yaml | 2 +- docs-requirements.txt | 10 +++++----- test-requirements.txt | 26 +++++++++++++------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38f8b73c9..ba16bc4d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.0 + rev: v0.8.1 hooks: - id: ruff types: [file] diff --git a/docs-requirements.txt b/docs-requirements.txt index 9698e5785..03cefbc9a 100644 --- a/docs-requirements.txt +++ b/docs-requirements.txt @@ -24,7 +24,7 @@ colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows' # via # click # sphinx -cryptography==43.0.3 +cryptography==44.0.0 # via pyopenssl docutils==0.21.2 # via @@ -49,13 +49,13 @@ markupsafe==3.0.2 # via jinja2 outcome==1.3.0.post0 # via -r docs-requirements.in -packaging==24.1 +packaging==24.2 # via sphinx pycparser==2.22 ; platform_python_implementation != 'PyPy' or os_name == 'nt' # via cffi pygments==2.18.0 # via sphinx -pyopenssl==24.2.1 +pyopenssl==24.3.0 # via -r docs-requirements.in requests==2.32.3 # via sphinx @@ -77,9 +77,9 @@ sphinx==8.1.3 # sphinxcontrib-trio sphinx-codeautolink==0.15.2 # via -r docs-requirements.in -sphinx-hoverxref==1.4.1 +sphinx-hoverxref==1.4.2 # via -r docs-requirements.in -sphinx-rtd-theme==3.0.1 +sphinx-rtd-theme==3.0.2 # via -r docs-requirements.in sphinxcontrib-applehelp==2.0.0 # via sphinx diff --git a/test-requirements.txt b/test-requirements.txt index efe920af0..9e2192d51 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -34,9 +34,9 @@ colorama==0.4.6 ; (implementation_name != 'cpython' and sys_platform == 'win32') # pylint # pytest # sphinx -coverage==7.6.4 +coverage==7.6.8 # via -r test-requirements.in -cryptography==43.0.3 +cryptography==44.0.0 # via # -r test-requirements.in # pyopenssl @@ -63,7 +63,7 @@ iniconfig==2.0.0 # via pytest isort==5.13.2 # via pylint -jedi==0.19.1 ; implementation_name == 'cpython' +jedi==0.19.2 ; implementation_name == 'cpython' # via -r test-requirements.in jinja2==3.1.4 # via sphinx @@ -80,11 +80,11 @@ mypy-extensions==1.0.0 # mypy nodeenv==1.9.1 # via pyright -orjson==3.10.10 ; implementation_name == 'cpython' +orjson==3.10.12 ; implementation_name == 'cpython' # via -r test-requirements.in outcome==1.3.0.post0 # via -r test-requirements.in -packaging==24.1 +packaging==24.2 # via # black # pytest @@ -105,15 +105,15 @@ pygments==2.18.0 # via sphinx pylint==3.3.1 # via -r test-requirements.in -pyopenssl==24.2.1 +pyopenssl==24.3.0 # via -r test-requirements.in -pyright==1.1.387 +pyright==1.1.389 # via -r test-requirements.in pytest==8.3.3 # via -r test-requirements.in requests==2.32.3 # via sphinx -ruff==0.8.0 +ruff==0.8.1 # via -r test-requirements.in sniffio==1.3.1 # via -r test-requirements.in @@ -135,7 +135,7 @@ sphinxcontrib-qthelp==2.0.0 # via sphinx sphinxcontrib-serializinghtml==2.0.0 # via sphinx -tomli==2.0.2 ; python_full_version < '3.11' +tomli==2.2.1 ; python_full_version < '3.11' # via # black # mypy @@ -150,11 +150,11 @@ types-cffi==1.16.0.20240331 # via # -r test-requirements.in # types-pyopenssl -types-docutils==0.21.0.20241005 +types-docutils==0.21.0.20241128 # via -r test-requirements.in types-pyopenssl==24.1.0.20240722 # via -r test-requirements.in -types-setuptools==75.2.0.20241025 +types-setuptools==75.6.0.20241126 # via types-cffi typing-extensions==4.12.2 # via @@ -166,7 +166,7 @@ typing-extensions==4.12.2 # pyright urllib3==2.2.3 # via requests -uv==0.4.29 +uv==0.5.5 # via -r test-requirements.in -zipp==3.20.2 ; python_full_version < '3.10' +zipp==3.21.0 ; python_full_version < '3.10' # via importlib-metadata From 65e9e4654975826edbe3f9b2e48b0dd7d2fdb68b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 00:56:07 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/trio/_core/_concat_tb.py | 2 +- src/trio/_core/_io_windows.py | 10 +++++----- src/trio/_core/_local.py | 2 +- src/trio/_core/_run.py | 6 +++--- src/trio/_core/_tests/test_guest_mode.py | 2 +- src/trio/_core/_traps.py | 2 +- src/trio/_core/_windows_cffi.py | 6 +++--- src/trio/_tests/test_highlevel_open_tcp_listeners.py | 2 +- src/trio/_tests/test_highlevel_serve_listeners.py | 2 +- src/trio/_tests/test_highlevel_ssl_helpers.py | 2 +- src/trio/_tests/test_socket.py | 2 +- src/trio/testing/_raises_group.py | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/trio/_core/_concat_tb.py b/src/trio/_core/_concat_tb.py index 82e525137..90f1505f7 100644 --- a/src/trio/_core/_concat_tb.py +++ b/src/trio/_core/_concat_tb.py @@ -107,7 +107,7 @@ def controller( # type: ignore[no-any-unimported] return operation.delegate() # type: ignore[no-any-return] return cast( - TracebackType, + "TracebackType", tputil.make_proxy(controller, type(base_tb), base_tb), ) # Returns proxy to traceback diff --git a/src/trio/_core/_io_windows.py b/src/trio/_core/_io_windows.py index c4325a286..1874f5c79 100644 --- a/src/trio/_core/_io_windows.py +++ b/src/trio/_core/_io_windows.py @@ -700,7 +700,7 @@ def _refresh_afd(self, base_handle: Handle) -> None: lpOverlapped = ffi.new("LPOVERLAPPED") - poll_info = cast(_AFDPollInfo, ffi.new("AFD_POLL_INFO *")) + poll_info = cast("_AFDPollInfo", ffi.new("AFD_POLL_INFO *")) poll_info.Timeout = 2**63 - 1 # INT64_MAX poll_info.NumberOfHandles = 1 poll_info.Exclusive = 0 @@ -713,9 +713,9 @@ def _refresh_afd(self, base_handle: Handle) -> None: kernel32.DeviceIoControl( afd_group.handle, IoControlCodes.IOCTL_AFD_POLL, - cast(CType, poll_info), + cast("CType", poll_info), ffi.sizeof("AFD_POLL_INFO"), - cast(CType, poll_info), + cast("CType", poll_info), ffi.sizeof("AFD_POLL_INFO"), ffi.NULL, lpOverlapped, @@ -937,13 +937,13 @@ async def _perform_overlapped( # operation will not be cancellable, depending on how Windows is # feeling today. So we need to check for cancellation manually. await _core.checkpoint_if_cancelled() - lpOverlapped = cast(_Overlapped, ffi.new("LPOVERLAPPED")) + lpOverlapped = cast("_Overlapped", ffi.new("LPOVERLAPPED")) try: submit_fn(lpOverlapped) except OSError as exc: if exc.winerror != ErrorCodes.ERROR_IO_PENDING: raise - await self.wait_overlapped(handle, cast(CData, lpOverlapped)) + await self.wait_overlapped(handle, cast("CData", lpOverlapped)) return lpOverlapped @_public diff --git a/src/trio/_core/_local.py b/src/trio/_core/_local.py index 53cbfc135..06dfef288 100644 --- a/src/trio/_core/_local.py +++ b/src/trio/_core/_local.py @@ -44,7 +44,7 @@ class RunVar(Generic[T]): def get(self, default: T | type[_NoValue] = _NoValue) -> T: """Gets the value of this :class:`RunVar` for the current run call.""" try: - return cast(T, _run.GLOBAL_RUN_CONTEXT.runner._locals[self]) + return cast("T", _run.GLOBAL_RUN_CONTEXT.runner._locals[self]) except AttributeError: raise RuntimeError("Cannot be used outside of a run context") from None except KeyError: diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py index 2bfe3254c..da97038bc 100644 --- a/src/trio/_core/_run.py +++ b/src/trio/_core/_run.py @@ -941,7 +941,7 @@ def started(self: _TaskStatus[StatusT], value: StatusT) -> None: ... def started(self, value: StatusT | None = None) -> None: if self._value is not _NoStatus: raise RuntimeError("called 'started' twice on the same task status") - self._value = cast(StatusT, value) # If None, StatusT == None + self._value = cast("StatusT", value) # If None, StatusT == None # If the old nursery is cancelled, then quietly quit now; the child # will eventually exit on its own, and we don't want to risk moving @@ -2407,7 +2407,7 @@ def run( # Inlined copy of runner.main_task_outcome.unwrap() to avoid # cluttering every single Trio traceback with an extra frame. if isinstance(runner.main_task_outcome, Value): - return cast(RetT, runner.main_task_outcome.value) + return cast("RetT", runner.main_task_outcome.value) elif isinstance(runner.main_task_outcome, Error): raise runner.main_task_outcome.error else: # pragma: no cover @@ -2531,7 +2531,7 @@ def my_done_callback(run_outcome): # this time, so it shouldn't be possible to get an exception here, # except for a TrioInternalError. next_send = cast( - EventResult, + "EventResult", None, ) # First iteration must be `None`, every iteration after that is EventResult for _tick in range(5): # expected need is 2 iterations + leave some wiggle room diff --git a/src/trio/_core/_tests/test_guest_mode.py b/src/trio/_core/_tests/test_guest_mode.py index 1a4f87464..526932b94 100644 --- a/src/trio/_core/_tests/test_guest_mode.py +++ b/src/trio/_core/_tests/test_guest_mode.py @@ -467,7 +467,7 @@ def trio_done_callback(main_outcome: Outcome[T]) -> None: trio_done_fut.set_result(main_outcome) if pass_not_threadsafe: - run_sync_soon_not_threadsafe = cast(InHost, loop.call_soon) + run_sync_soon_not_threadsafe = cast("InHost", loop.call_soon) trio.lowlevel.start_guest_run( trio_fn, diff --git a/src/trio/_core/_traps.py b/src/trio/_core/_traps.py index bef77b768..3a4942f42 100644 --- a/src/trio/_core/_traps.py +++ b/src/trio/_core/_traps.py @@ -67,7 +67,7 @@ def _real_async_yield( # Real yield value is from trio's main loop, but type checkers can't # understand that, so we cast it to make type checkers understand. _async_yield = cast( - Callable[[MessageType], Awaitable[outcome.Outcome[object]]], + "Callable[[MessageType], Awaitable[outcome.Outcome[object]]]", _real_async_yield, ) diff --git a/src/trio/_core/_windows_cffi.py b/src/trio/_core/_windows_cffi.py index 453b4beda..575fcb560 100644 --- a/src/trio/_core/_windows_cffi.py +++ b/src/trio/_core/_windows_cffi.py @@ -395,9 +395,9 @@ class _Overlapped(Protocol): hEvent: Handle -kernel32 = cast(_Kernel32, ffi.dlopen("kernel32.dll")) -ntdll = cast(_Nt, ffi.dlopen("ntdll.dll")) -ws2_32 = cast(_Ws2, ffi.dlopen("ws2_32.dll")) +kernel32 = cast("_Kernel32", ffi.dlopen("kernel32.dll")) +ntdll = cast("_Nt", ffi.dlopen("ntdll.dll")) +ws2_32 = cast("_Ws2", ffi.dlopen("ws2_32.dll")) ################################################################ # Magic numbers diff --git a/src/trio/_tests/test_highlevel_open_tcp_listeners.py b/src/trio/_tests/test_highlevel_open_tcp_listeners.py index 61abd43f0..e78e4414d 100644 --- a/src/trio/_tests/test_highlevel_open_tcp_listeners.py +++ b/src/trio/_tests/test_highlevel_open_tcp_listeners.py @@ -314,7 +314,7 @@ async def handler(stream: SendStream) -> None: # nursery.start is incorrectly typed, awaiting #2773 value = await nursery.start(serve_tcp, handler, 0) assert isinstance(value, list) - listeners = cast(list[SocketListener], value) + listeners = cast("list[SocketListener]", value) stream = await open_stream_to_socket_listener(listeners[0]) async with stream: assert await stream.receive_some(1) == b"x" diff --git a/src/trio/_tests/test_highlevel_serve_listeners.py b/src/trio/_tests/test_highlevel_serve_listeners.py index 013d13078..9268555b3 100644 --- a/src/trio/_tests/test_highlevel_serve_listeners.py +++ b/src/trio/_tests/test_highlevel_serve_listeners.py @@ -102,7 +102,7 @@ async def do_tests(parent_nursery: Nursery) -> None: listeners, ) assert isinstance(value, list) - l2 = cast(list[MemoryListener], value) + l2 = cast("list[MemoryListener]", value) assert l2 == listeners # This is just split into another function because gh-136 isn't # implemented yet diff --git a/src/trio/_tests/test_highlevel_ssl_helpers.py b/src/trio/_tests/test_highlevel_ssl_helpers.py index 68aa47846..416da3828 100644 --- a/src/trio/_tests/test_highlevel_ssl_helpers.py +++ b/src/trio/_tests/test_highlevel_ssl_helpers.py @@ -92,7 +92,7 @@ async def test_open_ssl_over_tcp_stream_and_everything_else( ), ) assert isinstance(value, list) - res = cast(list[SSLListener[SocketListener]], value) # type: ignore[type-var] + res = cast("list[SSLListener[SocketListener]]", value) # type: ignore[type-var] (listener,) = res async with listener: # listener.transport_listener is of type Listener[Stream] diff --git a/src/trio/_tests/test_socket.py b/src/trio/_tests/test_socket.py index dc4bb467a..8226d2e38 100644 --- a/src/trio/_tests/test_socket.py +++ b/src/trio/_tests/test_socket.py @@ -655,7 +655,7 @@ async def res( local=local, # noqa: B023 # local is not bound in function definition ) assert isinstance(value, tuple) - return cast(tuple[Union[str, int], ...], value) + return cast("tuple[Union[str, int], ...]", value) assert_eq(await res((addrs.arbitrary, "http")), (addrs.arbitrary, 80)) if v6: diff --git a/src/trio/testing/_raises_group.py b/src/trio/testing/_raises_group.py index 0fadfd962..700c16ca6 100644 --- a/src/trio/testing/_raises_group.py +++ b/src/trio/testing/_raises_group.py @@ -242,7 +242,7 @@ def matches(self, exception: BaseException) -> TypeGuard[MatchE]: return False # If exception_type is None check() accepts BaseException. # If non-none, we have done an isinstance check above. - return self.check is None or self.check(cast(MatchE, exception)) + return self.check is None or self.check(cast("MatchE", exception)) def __str__(self) -> str: reqs = [] From 4639c0aa433ff4ad6e8382b6b09f557baa8af035 Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 1 Dec 2024 13:03:13 -0500 Subject: [PATCH 3/6] Undo cryptography bump Need to wait for a trustme release, I think --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 9e2192d51..b61fc0ddc 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -36,7 +36,7 @@ colorama==0.4.6 ; (implementation_name != 'cpython' and sys_platform == 'win32') # sphinx coverage==7.6.8 # via -r test-requirements.in -cryptography==44.0.0 +cryptography==43.0.3 # via # -r test-requirements.in # pyopenssl From c0067bb644eb964a9adb4f2beaa776c48fe195c1 Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 1 Dec 2024 13:07:22 -0500 Subject: [PATCH 4/6] Revert pyOpenSSL, undo cryptography revert --- test-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index b61fc0ddc..89d3f3fd2 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -36,7 +36,7 @@ colorama==0.4.6 ; (implementation_name != 'cpython' and sys_platform == 'win32') # sphinx coverage==7.6.8 # via -r test-requirements.in -cryptography==43.0.3 +cryptography==44.0.0 # via # -r test-requirements.in # pyopenssl @@ -105,7 +105,7 @@ pygments==2.18.0 # via sphinx pylint==3.3.1 # via -r test-requirements.in -pyopenssl==24.3.0 +pyopenssl==24.2.1 # via -r test-requirements.in pyright==1.1.389 # via -r test-requirements.in From a6e28e97b46023d581c6d3c3b303682c2edde9be Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 1 Dec 2024 13:09:38 -0500 Subject: [PATCH 5/6] Revert cryptography again --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 89d3f3fd2..490b41ea5 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -36,7 +36,7 @@ colorama==0.4.6 ; (implementation_name != 'cpython' and sys_platform == 'win32') # sphinx coverage==7.6.8 # via -r test-requirements.in -cryptography==44.0.0 +cryptography==43.0.3 # via # -r test-requirements.in # pyopenssl From 064e0a4e366af5e8e156579082f7d7371ca2cdc2 Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Sun, 1 Dec 2024 13:16:58 -0500 Subject: [PATCH 6/6] Fix things for lints --- src/trio/_core/_concat_tb.py | 4 +++- src/trio/_core/_traps.py | 3 +-- src/trio/_tests/test_highlevel_ssl_helpers.py | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/trio/_core/_concat_tb.py b/src/trio/_core/_concat_tb.py index 90f1505f7..a1469618e 100644 --- a/src/trio/_core/_concat_tb.py +++ b/src/trio/_core/_concat_tb.py @@ -1,8 +1,10 @@ from __future__ import annotations -from types import TracebackType from typing import TYPE_CHECKING, ClassVar, cast +if TYPE_CHECKING: + from types import TracebackType + ################################################################ # concat_tb ################################################################ diff --git a/src/trio/_core/_traps.py b/src/trio/_core/_traps.py index 3a4942f42..1ddd5628b 100644 --- a/src/trio/_core/_traps.py +++ b/src/trio/_core/_traps.py @@ -4,7 +4,6 @@ import enum import types -from collections.abc import Awaitable # Jedi gets mad in test_static_tool_sees_class_members if we use collections Callable from typing import TYPE_CHECKING, Any, Callable, NoReturn, Union, cast @@ -15,7 +14,7 @@ from . import _run if TYPE_CHECKING: - from collections.abc import Generator + from collections.abc import Awaitable, Generator from typing_extensions import TypeAlias diff --git a/src/trio/_tests/test_highlevel_ssl_helpers.py b/src/trio/_tests/test_highlevel_ssl_helpers.py index 416da3828..e42f31198 100644 --- a/src/trio/_tests/test_highlevel_ssl_helpers.py +++ b/src/trio/_tests/test_highlevel_ssl_helpers.py @@ -10,13 +10,11 @@ import trio.testing from trio.socket import AF_INET, IPPROTO_TCP, SOCK_STREAM -from .._highlevel_socket import SocketListener from .._highlevel_ssl_helpers import ( open_ssl_over_tcp_listeners, open_ssl_over_tcp_stream, serve_ssl_over_tcp, ) -from .._ssl import SSLListener # using noqa because linters don't understand how pytest fixtures work. from .test_ssl import SERVER_CTX, client_ctx # noqa: F401 @@ -27,6 +25,9 @@ from trio.abc import Stream + from .._highlevel_socket import SocketListener + from .._ssl import SSLListener + async def echo_handler(stream: Stream) -> None: async with stream: