From 27bf566d75dee66562711df5d1ec87c38c1acde6 Mon Sep 17 00:00:00 2001 From: goodboy Date: Fri, 10 Apr 2026 12:05:56 -0400 Subject: [PATCH] Guard `_mp_fixup_main` on non-empty parent data Use walrus `:=` to combine the assignment and truthiness check for `_parent_main_data` into the `if` condition, cleanly skipping the fixup block when `inherit_parent_main=False` yields `{}`. Review: PR #438 (Copilot) https://github.com/goodboy/tractor/pull/438 (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tractor/runtime/_runtime.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tractor/runtime/_runtime.py b/tractor/runtime/_runtime.py index b5968640..477d8f9b 100644 --- a/tractor/runtime/_runtime.py +++ b/tractor/runtime/_runtime.py @@ -552,11 +552,15 @@ class Actor: ''' try: - if self._spawn_method == 'trio': - parent_data = self._parent_main_data + if ( + self._spawn_method == 'trio' + and + (parent_data := self._parent_main_data) + ): if 'init_main_from_name' in parent_data: _mp_fixup_main._fixup_main_from_name( parent_data['init_main_from_name']) + elif 'init_main_from_path' in parent_data: _mp_fixup_main._fixup_main_from_path( parent_data['init_main_from_path'])