Skip to content

Commit

Permalink
Merge pull request #2788 from python-trio/fix-2696-2700
Browse files Browse the repository at this point in the history
Fix type errors introduced when #2696 and #2700 were merged
  • Loading branch information
richardsheridan authored Sep 3, 2023
2 parents 8304dce + dacd4b3 commit 4d19399
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
12 changes: 8 additions & 4 deletions trio/_core/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion trio/_core/_tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion trio/_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ def callback(
fn: Callable[..., RetT],
args: tuple[object, ...],
) -> None:

@disable_ki_protection
def unprotected_fn() -> RetT:
ret = fn(*args)
Expand Down

0 comments on commit 4d19399

Please sign in to comment.