Skip to content

Commit 65e9e46

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1194c57 commit 65e9e46

12 files changed

+20
-20
lines changed

src/trio/_core/_concat_tb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def controller( # type: ignore[no-any-unimported]
107107
return operation.delegate() # type: ignore[no-any-return]
108108

109109
return cast(
110-
TracebackType,
110+
"TracebackType",
111111
tputil.make_proxy(controller, type(base_tb), base_tb),
112112
) # Returns proxy to traceback
113113

src/trio/_core/_io_windows.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def _refresh_afd(self, base_handle: Handle) -> None:
700700

701701
lpOverlapped = ffi.new("LPOVERLAPPED")
702702

703-
poll_info = cast(_AFDPollInfo, ffi.new("AFD_POLL_INFO *"))
703+
poll_info = cast("_AFDPollInfo", ffi.new("AFD_POLL_INFO *"))
704704
poll_info.Timeout = 2**63 - 1 # INT64_MAX
705705
poll_info.NumberOfHandles = 1
706706
poll_info.Exclusive = 0
@@ -713,9 +713,9 @@ def _refresh_afd(self, base_handle: Handle) -> None:
713713
kernel32.DeviceIoControl(
714714
afd_group.handle,
715715
IoControlCodes.IOCTL_AFD_POLL,
716-
cast(CType, poll_info),
716+
cast("CType", poll_info),
717717
ffi.sizeof("AFD_POLL_INFO"),
718-
cast(CType, poll_info),
718+
cast("CType", poll_info),
719719
ffi.sizeof("AFD_POLL_INFO"),
720720
ffi.NULL,
721721
lpOverlapped,
@@ -937,13 +937,13 @@ async def _perform_overlapped(
937937
# operation will not be cancellable, depending on how Windows is
938938
# feeling today. So we need to check for cancellation manually.
939939
await _core.checkpoint_if_cancelled()
940-
lpOverlapped = cast(_Overlapped, ffi.new("LPOVERLAPPED"))
940+
lpOverlapped = cast("_Overlapped", ffi.new("LPOVERLAPPED"))
941941
try:
942942
submit_fn(lpOverlapped)
943943
except OSError as exc:
944944
if exc.winerror != ErrorCodes.ERROR_IO_PENDING:
945945
raise
946-
await self.wait_overlapped(handle, cast(CData, lpOverlapped))
946+
await self.wait_overlapped(handle, cast("CData", lpOverlapped))
947947
return lpOverlapped
948948

949949
@_public

src/trio/_core/_local.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class RunVar(Generic[T]):
4444
def get(self, default: T | type[_NoValue] = _NoValue) -> T:
4545
"""Gets the value of this :class:`RunVar` for the current run call."""
4646
try:
47-
return cast(T, _run.GLOBAL_RUN_CONTEXT.runner._locals[self])
47+
return cast("T", _run.GLOBAL_RUN_CONTEXT.runner._locals[self])
4848
except AttributeError:
4949
raise RuntimeError("Cannot be used outside of a run context") from None
5050
except KeyError:

src/trio/_core/_run.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ def started(self: _TaskStatus[StatusT], value: StatusT) -> None: ...
941941
def started(self, value: StatusT | None = None) -> None:
942942
if self._value is not _NoStatus:
943943
raise RuntimeError("called 'started' twice on the same task status")
944-
self._value = cast(StatusT, value) # If None, StatusT == None
944+
self._value = cast("StatusT", value) # If None, StatusT == None
945945

946946
# If the old nursery is cancelled, then quietly quit now; the child
947947
# will eventually exit on its own, and we don't want to risk moving
@@ -2407,7 +2407,7 @@ def run(
24072407
# Inlined copy of runner.main_task_outcome.unwrap() to avoid
24082408
# cluttering every single Trio traceback with an extra frame.
24092409
if isinstance(runner.main_task_outcome, Value):
2410-
return cast(RetT, runner.main_task_outcome.value)
2410+
return cast("RetT", runner.main_task_outcome.value)
24112411
elif isinstance(runner.main_task_outcome, Error):
24122412
raise runner.main_task_outcome.error
24132413
else: # pragma: no cover
@@ -2531,7 +2531,7 @@ def my_done_callback(run_outcome):
25312531
# this time, so it shouldn't be possible to get an exception here,
25322532
# except for a TrioInternalError.
25332533
next_send = cast(
2534-
EventResult,
2534+
"EventResult",
25352535
None,
25362536
) # First iteration must be `None`, every iteration after that is EventResult
25372537
for _tick in range(5): # expected need is 2 iterations + leave some wiggle room

src/trio/_core/_tests/test_guest_mode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def trio_done_callback(main_outcome: Outcome[T]) -> None:
467467
trio_done_fut.set_result(main_outcome)
468468

469469
if pass_not_threadsafe:
470-
run_sync_soon_not_threadsafe = cast(InHost, loop.call_soon)
470+
run_sync_soon_not_threadsafe = cast("InHost", loop.call_soon)
471471

472472
trio.lowlevel.start_guest_run(
473473
trio_fn,

src/trio/_core/_traps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _real_async_yield(
6767
# Real yield value is from trio's main loop, but type checkers can't
6868
# understand that, so we cast it to make type checkers understand.
6969
_async_yield = cast(
70-
Callable[[MessageType], Awaitable[outcome.Outcome[object]]],
70+
"Callable[[MessageType], Awaitable[outcome.Outcome[object]]]",
7171
_real_async_yield,
7272
)
7373

src/trio/_core/_windows_cffi.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,9 @@ class _Overlapped(Protocol):
395395
hEvent: Handle
396396

397397

398-
kernel32 = cast(_Kernel32, ffi.dlopen("kernel32.dll"))
399-
ntdll = cast(_Nt, ffi.dlopen("ntdll.dll"))
400-
ws2_32 = cast(_Ws2, ffi.dlopen("ws2_32.dll"))
398+
kernel32 = cast("_Kernel32", ffi.dlopen("kernel32.dll"))
399+
ntdll = cast("_Nt", ffi.dlopen("ntdll.dll"))
400+
ws2_32 = cast("_Ws2", ffi.dlopen("ws2_32.dll"))
401401

402402
################################################################
403403
# Magic numbers

src/trio/_tests/test_highlevel_open_tcp_listeners.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ async def handler(stream: SendStream) -> None:
314314
# nursery.start is incorrectly typed, awaiting #2773
315315
value = await nursery.start(serve_tcp, handler, 0)
316316
assert isinstance(value, list)
317-
listeners = cast(list[SocketListener], value)
317+
listeners = cast("list[SocketListener]", value)
318318
stream = await open_stream_to_socket_listener(listeners[0])
319319
async with stream:
320320
assert await stream.receive_some(1) == b"x"

src/trio/_tests/test_highlevel_serve_listeners.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async def do_tests(parent_nursery: Nursery) -> None:
102102
listeners,
103103
)
104104
assert isinstance(value, list)
105-
l2 = cast(list[MemoryListener], value)
105+
l2 = cast("list[MemoryListener]", value)
106106
assert l2 == listeners
107107
# This is just split into another function because gh-136 isn't
108108
# implemented yet

src/trio/_tests/test_highlevel_ssl_helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async def test_open_ssl_over_tcp_stream_and_everything_else(
9292
),
9393
)
9494
assert isinstance(value, list)
95-
res = cast(list[SSLListener[SocketListener]], value) # type: ignore[type-var]
95+
res = cast("list[SSLListener[SocketListener]]", value) # type: ignore[type-var]
9696
(listener,) = res
9797
async with listener:
9898
# listener.transport_listener is of type Listener[Stream]

src/trio/_tests/test_socket.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ async def res(
655655
local=local, # noqa: B023 # local is not bound in function definition
656656
)
657657
assert isinstance(value, tuple)
658-
return cast(tuple[Union[str, int], ...], value)
658+
return cast("tuple[Union[str, int], ...]", value)
659659

660660
assert_eq(await res((addrs.arbitrary, "http")), (addrs.arbitrary, 80))
661661
if v6:

src/trio/testing/_raises_group.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def matches(self, exception: BaseException) -> TypeGuard[MatchE]:
242242
return False
243243
# If exception_type is None check() accepts BaseException.
244244
# If non-none, we have done an isinstance check above.
245-
return self.check is None or self.check(cast(MatchE, exception))
245+
return self.check is None or self.check(cast("MatchE", exception))
246246

247247
def __str__(self) -> str:
248248
reqs = []

0 commit comments

Comments
 (0)