From 92f82a9c6850dc17694169b89d0a1c431e82fd05 Mon Sep 17 00:00:00 2001 From: Musa Date: Fri, 24 Apr 2026 16:18:11 -0700 Subject: [PATCH] fix(cli): drop function-local `import yaml` shadowing module global in `up` (#916) `up()` had a redundant inline `import yaml` (line 444) even though `yaml` is already imported at the module top (line 9). Python's compile-time scope analysis turned `yaml` into a function-local for the entire body, which was harmless until #890 added `yaml.safe_dump(...)` earlier in the same function (in the synthesized-default-config branch). After #890, running `planoai up` in any directory without a config file crashes with: UnboundLocalError: cannot access local variable 'yaml' where it is not associated with a value File "cli/planoai/main.py", line 388, in up yaml.safe_dump(cfg_dict, fh, sort_keys=False) Removing the redundant inline import lets the module-level `yaml` resolve normally on both code paths. --- cli/planoai/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/cli/planoai/main.py b/cli/planoai/main.py index 8e766cf8..ea43a1a8 100644 --- a/cli/planoai/main.py +++ b/cli/planoai/main.py @@ -441,8 +441,6 @@ def up( env = os.environ.copy() env.pop("PATH", None) - import yaml - with open(plano_config_file, "r") as f: plano_config = yaml.safe_load(f)