From 56fbed0be19d278c69f8044d69d9dafebf1cbea5 Mon Sep 17 00:00:00 2001 From: goodboy Date: Thu, 2 Jul 2026 12:35:37 -0400 Subject: [PATCH] Type the remaining niche examples Finish the examples-typing sweep with the last non-docs-visible scripts: `-> None` on the two `trio/` behavior-demo mains (plus a `trio.TaskStatus` on `hold_lock_forever`) and nursery/portal typing on `integration/mpi4py/inherit_parent_main.py`. Leaves `concurrent_futures_primes` (a verbatim stdlib baseline) and `integration/open_context_and_sleep` (its tractor nursery is commented out) as-is, and the paren-group `trio.open_nursery()` bindings unannotated (no clean spot for a preceding annotation). Completes the examples-typing bullet in #472. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- examples/integration/mpi4py/inherit_parent_main.py | 5 +++-- examples/trio/lockacquire_not_unmasked.py | 6 +++--- examples/trio/send_chan_aclose_masks_beg.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/integration/mpi4py/inherit_parent_main.py b/examples/integration/mpi4py/inherit_parent_main.py index 60e30a95..741d8a6b 100644 --- a/examples/integration/mpi4py/inherit_parent_main.py +++ b/examples/integration/mpi4py/inherit_parent_main.py @@ -33,15 +33,16 @@ async def main() -> None: rank = MPI.COMM_WORLD.Get_rank() print(f"[parent] rank={rank} pid={os.getpid()}", flush=True) + an: tractor.ActorNursery async with tractor.open_nursery(start_method='trio') as an: - portal = await an.start_actor( + portal: tractor.Portal = await an.start_actor( 'mpi-child', enable_modules=[child_fn.__module__], # Without this the child replays __main__, which # re-imports mpi4py and crashes on MPI_Init. inherit_parent_main=False, ) - result = await portal.run(child_fn) + result: str = await portal.run(child_fn) print(f"[parent] got: {result}", flush=True) await portal.cancel_actor() diff --git a/examples/trio/lockacquire_not_unmasked.py b/examples/trio/lockacquire_not_unmasked.py index 2f979a00..19077706 100644 --- a/examples/trio/lockacquire_not_unmasked.py +++ b/examples/trio/lockacquire_not_unmasked.py @@ -32,8 +32,8 @@ async def acquire_singleton_lock( async def hold_lock_forever( - task_status=trio.TASK_STATUS_IGNORED -): + task_status: trio.TaskStatus = trio.TASK_STATUS_IGNORED, +) -> None: async with ( tractor.trionics.maybe_raise_from_masking_exc(), acquire_singleton_lock() as lock, @@ -46,7 +46,7 @@ async def main( ignore_special_cases: bool, loglevel: str = 'info', debug_mode: bool = True, -): +) -> None: async with ( trio.open_nursery() as tn, diff --git a/examples/trio/send_chan_aclose_masks_beg.py b/examples/trio/send_chan_aclose_masks_beg.py index e7f895b7..971d8678 100644 --- a/examples/trio/send_chan_aclose_masks_beg.py +++ b/examples/trio/send_chan_aclose_masks_beg.py @@ -134,7 +134,7 @@ async def main( raise_unmasked: bool = False, loglevel: str = 'info', -): +) -> None: tractor.log.get_console_log(level=loglevel) # the `.aclose()` being checkpoints on these