From b0ac681245d273598006ad1d735f27289ff3c38c Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 17 Jun 2026 19:46:43 -0400 Subject: [PATCH] Fix dead-code env-var override notice in `open_root_actor` The `TRACTOR_LOGLEVEL`/`TRACTOR_SPAWN_METHOD` override-notice branches were unreachable: `loglevel`/`start_method` were reassigned to the env value BEFORE the `!=` compare, so the "OVERRIDES caller-passed" message never fired. Capture the caller value first, then compare. Rel. `208e7c09`/`d4eac06d` "Honor env-vars" (`trionics.start_or_cancel`); surfaced by `/code-review high` on #462. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tractor/_root.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tractor/_root.py b/tractor/_root.py index 78a1be56..6e31d0a1 100644 --- a/tractor/_root.py +++ b/tractor/_root.py @@ -290,6 +290,10 @@ async def open_root_actor( # console verbosity without touching application code. env_ll_report: str = '' if env_ll := os.environ.get('TRACTOR_LOGLEVEL'): + # capture the caller-passed value BEFORE the env-var + # clobbers it, else the override-notice below is dead + # code (the `!=` compare is always `False`). + caller_ll: str|None = loglevel loglevel = env_ll env_ll_report: str = ( f'Detected env-var setting,\n' @@ -299,14 +303,14 @@ async def open_root_actor( f'loglevel={loglevel!r}\n' ) if ( - loglevel + caller_ll and - loglevel.upper() != env_ll.upper() + caller_ll.upper() != env_ll.upper() ): env_ll_report += ( f'\n' f'NOTE env-var OVERRIDES caller-passed,\n' - f'loglevel={loglevel!r}\n' + f'loglevel={caller_ll!r}\n' ) loglevel: str = ( @@ -332,6 +336,9 @@ async def open_root_actor( # the `examples/debugging/