From f706477f18538e6faed028dcbec7117ab0e5fc45 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Fri, 14 Aug 2026 23:55:05 +0200 Subject: [PATCH] lib.App: Use args parameter in _run() _run() receives the parsed arguments as its args parameter, but then checks the private __args attribute for the func attribute and resolves the command function through the args property. Both refer to the same object today, so the mixing is harmless, but it obscures the data flow and would silently diverge if a caller ever passed a namespace other than the stored one. Use the args parameter consistently in _run(). Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/App.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python/jw/pkg/lib/App.py b/src/python/jw/pkg/lib/App.py index b106b216..276816b2 100644 --- a/src/python/jw/pkg/lib/App.py +++ b/src/python/jw/pkg/lib/App.py @@ -318,11 +318,11 @@ class App: # export # want to do something else, for instance if you don't have sub-commands, # or if want to do anything before and / or after the subcommands. async def _run(self, args: Namespace) -> None | int: - if not hasattr(self.__args, 'func'): + if not hasattr(args, 'func'): self.__parser.print_help() return None # Run sub-command. Overwrite if you want to do anything before or after - return cast('None | int', await self.args.func(args)) + return cast('None | int', await args.func(args)) def call_async(self, awaitable: Awaitable[T], timeout: float | None = None) -> T: return self.async_runner.call(awaitable, timeout)