jw-python/src
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jan Lindemann 4d49b508bc
stree: Type annotate StringTree and serdes
The StringTree class and its companion serdes module have minimal
type annotations — only method signatures and a few instance
attributes were typed. This commit adds proper type annotations to
every parameter, return type, and local variable across both files.

cleanup_string() gains overloaded signatures so callers passing str
get str back, avoiding the need to widen the return type everywhere.
The matcher return type in __find is narrowed from Any to
Callable[[str, str], bool]. Casts are used sparingly where the
runtime guarantees a narrower type than the checker can infer (e.g.
self.value() always returns str when called without path, despite the
return annotation being str | None).

Variable annotations in StringTree.__set, get, __find, child_list, and
dump cover local bindings. serdes gains full parameter and return type
coverage plus annotations for all local variables in _cleanup_line,
parse, _read_lines_from_one_path, and _read_lines.

The get() default parameter remains Any because overriding
Mapping.get with a concrete type breaks the Liskov substitution
principle — Mapping.get is generic over the default type.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-08-12 23:10:12 +00:00
..
python stree: Type annotate StringTree and serdes 2026-08-12 23:10:12 +00:00
Makefile jwutils: Move to jwutils -> jw.util 2026-06-11 23:10:25 +00:00