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 <jan@janware.com>
This commit is contained in:
parent
3fce4b27f8
commit
f706477f18
1 changed files with 2 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue