App: Miscellaneous fixes and improvements based on AI code analysis #44

Merged
Jan Lindemann merged 8 commits from jan/feature/20260630-app-get-values-filter-out-empty-split-results into master 2026-06-30 15:21:31 +02:00 AGit
Showing only changes of commit 59a0e2ada8 - Show all commits

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>
Jan Lindemann 2026-06-30 07:07:13 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -126,10 +126,14 @@ class App(Base):
def __find_dir( def __find_dir(
self, self,
name: str, name: str,
search_subdirs: list[str] = [], search_subdirs: list[str] | None = None,
search_absdirs: list[str] = [], search_absdirs: list[str] | None = None,
pretty: bool = True, pretty: bool = True,
) -> str | None: ) -> str | None:
if search_subdirs is None:
search_subdirs = []
if search_absdirs is None:
search_absdirs = []
def __format_relpath(path: str): def __format_relpath(path: str):
if path.startswith('./'): if path.startswith('./'):
@ -488,8 +492,8 @@ class App(Base):
def find_dir( def find_dir(
self, self,
name: str, name: str,
search_subdirs: list[str] = [], search_subdirs: list[str] | None = None,
search_absdirs: list[str] = [], search_absdirs: list[str] | None = None,
pretty: bool = True, pretty: bool = True,
throw: bool = False, throw: bool = False,
) -> str | None: ) -> str | None: