diff --git a/trio/_core/_run.py b/trio/_core/_run.py index c5c16803b0..b2f3a65ddd 100644 --- a/trio/_core/_run.py +++ b/trio/_core/_run.py @@ -200,8 +200,7 @@ def collapse_exception_group( ) return exceptions[0] elif modified: - # derive() returns Any for some reason. - return excgroup.derive(exceptions) # type: ignore[no-any-return] + return excgroup.derive(exceptions) else: return excgroup @@ -2358,7 +2357,9 @@ def my_done_callback(run_outcome): # spawn_system_task. We don't actually run any user code during # this time, so it shouldn't be possible to get an exception here, # except for a TrioInternalError. - next_send = None + next_send = cast( + 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 if runner.system_nursery is not None: # We're initialized enough to switch to async guest ticks @@ -2379,7 +2380,10 @@ def my_done_callback(run_outcome): # IOManager.get_events() if no I/O was waiting, which is # platform-dependent. We don't actually check for I/O during # this init phase because no one should be expecting any yet. - next_send = 0 if sys.platform == "win32" else () + if sys.platform == "win32": + next_send = 0 + else: + next_send = [] else: # pragma: no cover guest_state.unrolled_run_gen.throw( TrioInternalError( diff --git a/trio/_core/_tests/test_run.py b/trio/_core/_tests/test_run.py index 0b15b606fb..5c45cf828f 100644 --- a/trio/_core/_tests/test_run.py +++ b/trio/_core/_tests/test_run.py @@ -2066,7 +2066,7 @@ def check_function_returning_coroutine() -> Awaitable[object]: sniffio.current_async_library() @contextmanager - def alternate_sniffio_library(): + def alternate_sniffio_library() -> Generator[None, None, None]: prev_token = sniffio.current_async_library_cvar.set("nullio") prev_library, sniffio.thread_local.name = sniffio.thread_local.name, "nullio" try: diff --git a/trio/_threads.py b/trio/_threads.py index 2780fb6446..24905cfbde 100644 --- a/trio/_threads.py +++ b/trio/_threads.py @@ -409,7 +409,6 @@ def callback( fn: Callable[..., RetT], args: tuple[object, ...], ) -> None: - @disable_ki_protection def unprotected_fn() -> RetT: ret = fn(*args)