From 92747002461e0ccd42063ac9afd5b860f5f35af5 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sat, 15 Aug 2026 22:17:13 +0200 Subject: [PATCH] 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 --- src/python/jw/pkg/App.py | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/python/jw/pkg/App.py b/src/python/jw/pkg/App.py index 7abc3040..cffb1972 100644 --- a/src/python/jw/pkg/App.py +++ b/src/python/jw/pkg/App.py @@ -199,25 +199,24 @@ class App(Base): ), ) vals_list = vals.split(',') if vals else [] - match scope: - case Scope.Self: - buf += vals_list - case Scope.One | Scope.Subtree: - subscope = scope.Self if scope == Scope.One else scope - for val in vals_list: - val = val.strip() - if not (len(val)): - continue - self.__get_project_refs( - buf, - visited, - val, - section, - key, - add_self = True, - scope = subscope, - names_only = names_only, - ) + if scope != Scope.Self: + # Scope.Self adds the node itself (if add_self), but not its + # children, so stop recursing here + subscope = scope.Self if scope == Scope.One else scope + for val in vals_list: + val = val.strip() + if not (len(val)): + continue + self.__get_project_refs( + buf, + visited, + val, + section, + key, + add_self = True, + scope = subscope, + names_only = names_only, + ) if add_self: buf.append(spec)