From e2449e0591482d983a9c75e97ddb7c5b5e79bf21 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Mon, 9 Nov 2026 19:38:36 +0100 Subject: [PATCH] lib.ExecApp, ec.Local: Don't use keyword "local" as URI ExecApp's --target parameter and the ec.Local.__init__()'s uri argument carry "local" as their default value which was meant as a keyword but doesn't pass as an URI. Fix that. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0 Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/ExecApp.py | 2 +- src/python/jw/pkg/lib/ec/Local.py | 2 +- test/integration/jw_pkg/help/test-expected.txt | 2 +- .../python/jw/pkg/cmds/secrets/lib/FilesContext/test.py | 4 ++-- test/unit/python/jw/pkg/lib/ExecApp/test.py | 6 +++++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/python/jw/pkg/lib/ExecApp.py b/src/python/jw/pkg/lib/ExecApp.py index f84d85b1..35af49d8 100644 --- a/src/python/jw/pkg/lib/ExecApp.py +++ b/src/python/jw/pkg/lib/ExecApp.py @@ -46,7 +46,7 @@ class ExecApp(Base): # export help = "Be verbose on stderr about what's being done on the distro level", ) parser.add_argument( - '--target', default = 'local', help = 'Run commands on this host' + '--target', default = 'local://', help = 'Run commands on this host' ) parser.add_argument( '--path-filter', diff --git a/src/python/jw/pkg/lib/ec/Local.py b/src/python/jw/pkg/lib/ec/Local.py index 24e55642..cce2fe2b 100644 --- a/src/python/jw/pkg/lib/ec/Local.py +++ b/src/python/jw/pkg/lib/ec/Local.py @@ -21,7 +21,7 @@ if TYPE_CHECKING: class Local(Base): - def __init__(self, uri: str | Uri = 'local', *args: Any, **kwargs: Any) -> None: + def __init__(self, uri: str | Uri = 'local://', *args: Any, **kwargs: Any) -> None: super().__init__(uri, *args, **kwargs) @cache diff --git a/test/integration/jw_pkg/help/test-expected.txt b/test/integration/jw_pkg/help/test-expected.txt index 975b67bb..0c711ccf 100644 --- a/test/integration/jw_pkg/help/test-expected.txt +++ b/test/integration/jw_pkg/help/test-expected.txt @@ -24,7 +24,7 @@ options: (default: true) --verbose Be verbose on stderr about what's being done on the distro level (default: False) - --target TARGET Run commands on this host (default: local) + --target TARGET Run commands on this host (default: local://) --path-filter PATH_FILTER Default path filter for the exec context, as a name:spec loader string (default: None) diff --git a/test/unit/python/jw/pkg/cmds/secrets/lib/FilesContext/test.py b/test/unit/python/jw/pkg/cmds/secrets/lib/FilesContext/test.py index 90e7944f..11937687 100644 --- a/test/unit/python/jw/pkg/cmds/secrets/lib/FilesContext/test.py +++ b/test/unit/python/jw/pkg/cmds/secrets/lib/FilesContext/test.py @@ -9,10 +9,10 @@ import tempfile from typing import TYPE_CHECKING, override -from jw.pkg.cmds.secrets.lib.FilesContext import FilesContext from jw.pkg.cmds.secrets.lib.base import Attrs -from jw.pkg.lib.PathFilter import Verdict +from jw.pkg.cmds.secrets.lib.FilesContext import FilesContext from jw.pkg.lib.ec.Local import Local +from jw.pkg.lib.PathFilter import Verdict if TYPE_CHECKING: import os diff --git a/test/unit/python/jw/pkg/lib/ExecApp/test.py b/test/unit/python/jw/pkg/lib/ExecApp/test.py index b0071e56..4f4a0c31 100644 --- a/test/unit/python/jw/pkg/lib/ExecApp/test.py +++ b/test/unit/python/jw/pkg/lib/ExecApp/test.py @@ -52,9 +52,13 @@ opts = [o for a in app.parser._actions for o in getattr(a, 'option_strings', ()) for opt in ('--interactive', '--verbose', '--target'): assert opt in opts, f'{opt} must be registered by ExecApp' +# -- The default target is a conforming URI: a bare keyword would +# be parsed as a file path, and a downstream URI round-trip +# would misread it as a hostname +assert app.parser.get_default('target') == 'local://' + # -- Exiting the async context must close the app, through the # App.__aexit__() that ExecApp.__aexit__() chains to. - async def exit_context() -> None: async with app: pass -- 2.56.1