Skip to content

Fix type errors introduced when #2696 and #2700 were merged #2788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: EventResult = 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