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 <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-06-30 07:07:13 +02:00
commit 59a0e2ada8
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -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: