From 59a0e2ada866fbe3586689c6582633ee66bc80ae Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 30 Jun 2026 07:07:13 +0200 Subject: [PATCH] App.find_dir/__find_dir(): Fix mutable default args Mutable default arguments (list) cause unexpected shared state between calls. Use None as default and initialise to [] inside the function body. Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev Signed-off-by: Jan Lindemann --- src/python/jw/pkg/App.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/python/jw/pkg/App.py b/src/python/jw/pkg/App.py index 443b5d1d..894b62aa 100644 --- a/src/python/jw/pkg/App.py +++ b/src/python/jw/pkg/App.py @@ -126,10 +126,14 @@ class App(Base): def __find_dir( self, name: str, - search_subdirs: list[str] = [], - search_absdirs: list[str] = [], + search_subdirs: list[str] | None = None, + search_absdirs: list[str] | None = None, pretty: bool = True, ) -> str | None: + if search_subdirs is None: + search_subdirs = [] + if search_absdirs is None: + search_absdirs = [] def __format_relpath(path: str): if path.startswith('./'): @@ -488,8 +492,8 @@ class App(Base): def find_dir( self, name: str, - search_subdirs: list[str] = [], - search_absdirs: list[str] = [], + search_subdirs: list[str] | None = None, + search_absdirs: list[str] | None = None, pretty: bool = True, throw: bool = False, ) -> str | None: