lib.ExecApp: Add class #76

Closed
Jan Lindemann wants to merge 17 commits from jan/feature/20260822-lib-execapp-add-class into master AGit
Showing only changes of commit 9274700246 - Show all commits

App.__get_project_refs(): Skip children for Scope.Self

__get_project_refs() appends the values of a node to the result buffer
when the scope is Scope.Self. That is wrong: Scope.Self means "no
children", so a node visited with Scope.Self is supposed to contribute
only itself (if add_self is set), never its children. A previous
refactor that turned the scope handling into a match/case block
accidentally changed that, and as a consequence get_project_refs()
with scope=Scope.One now returns the direct dependencies plus their
dependencies. The second-level entries are raw values: they are not
stripped of whitespace, and they are not reduced to module names even
when names_only is True. The spurious self-edges this injects into the
dependency graph built by __read_dep_graph() make find_circular_deps()
report cycles that do not exist in the direct dependency graph.

Restore the original semantics by not recursing into children when the
scope is Scope.Self.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann 2026-08-15 22:17:13 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -199,25 +199,24 @@ class App(Base):
), ),
) )
vals_list = vals.split(',') if vals else [] vals_list = vals.split(',') if vals else []
match scope: if scope != Scope.Self:
case Scope.Self: # Scope.Self adds the node itself (if add_self), but not its
buf += vals_list # children, so stop recursing here
case Scope.One | Scope.Subtree: subscope = scope.Self if scope == Scope.One else scope
subscope = scope.Self if scope == Scope.One else scope for val in vals_list:
for val in vals_list: val = val.strip()
val = val.strip() if not (len(val)):
if not (len(val)): continue
continue self.__get_project_refs(
self.__get_project_refs( buf,
buf, visited,
visited, val,
val, section,
section, key,
key, add_self = True,
add_self = True, scope = subscope,
scope = subscope, names_only = names_only,
names_only = names_only, )
)
if add_self: if add_self:
buf.append(spec) buf.append(spec)