Repository navigation
Description
What happened?
Since 0.9.62, calling a project class whose name also appears in a type annotation in the same file drops the
calls edge to its constructor. 0.9.61 and older resolve it. Still reproduces on 0.9.70 and on v8@4c21b15e9b.
Two shapes, same root:
-
A. annotation in another function: the annotation leaves a sourceless stub node
Parserin the file.
Inextractors/engine.pythe in-file resolution bindsParser()to that stub. Then neither branch runs, so
the call is emitted neither as an edge nor as a raw call:external_stub_target = bool(tgt_nid and not nid_to_sf.get(tgt_nid)) if tgt_nid and not external_stub_target: ... # emits calls elif callee_name and not tgt_nid: ... # raw_call for cross-file resolution
Before Suppress sourceless external call targets like FastAPI HTTPException from bridge analysis #3156 the edge to the stub was emitted and later remapped to the real class.
-
B. annotation in the same function (
def detect(self) -> Parser: return Parser()): even when the call
reaches the cross-file pass, it is skipped because the pair already has the annotation edge:
if tgt != caller and (caller, tgt) not in existing_pairs:(extract.py). Before, the in-filecallsand the
genericreferencescollapsed in build (_GENERIC_RELATIONS, specific beats generic).
Steps to reproduce
mkdir -p repro/app/engines/transcript && cd repro
touch app/engines/__init__.py app/engines/transcript/__init__.py
cat > app/engines/transcript/parser.py <<'EOF'
class Parser:
def feed(self, line):
return line
EOF
cat > app/engines/engine.py <<'EOF'
from typing import Optional
from engines.transcript.parser import Parser
class Engine:
def detect(self): # shape A
return Parser()
def get_parser(self) -> Optional[Parser]:
return None
def make(self) -> Parser: # shape B
return Parser()
EOF
git init -q . && graphify update .Error output or graph output
edges from app/engines/engine.py
0.9.57, 0.9.61: calls .detect()->Parser; calls .make()->Parser; references .get_parser()->Parser
0.9.62, 0.9.70: references .get_parser()->Parser; references .make()->Parser <- both calls lost
0.9.70 + shape-A fix: calls .detect()->Parser; references .get_parser(); references .make()
0.9.70 + shape-A + B fixes: calls .detect()->Parser; calls .make()->Parser; references .get_parser()
controls: no annotation -> calls on every version;
external class (fastapi.HTTPException) annotated + called -> only references on 0.9.62+ (the #3156
intent), unchanged by the patches below
Suggested fix, measured on 0.9.70:
-
Shape A, one line in
extractors/engine.py: let a call bound to a sourceless stub fall through to
cross-file resolution, where the Suppress sourceless external call targets like FastAPI HTTPException from bridge analysis #3156 guard still drops truly external targets:- elif callee_name and not tgt_nid: + elif callee_name and (not tgt_nid or external_stub_target):
Restores shape A (12 of 48 lost constructor edges in our repo). External-class control unchanged.
-
Shape B: a pair that has only generic edges (
references/uses/mentions) should not block acalls,
which build then collapses. We tried this (ageneric_only_pairsset checked next toexisting_pairsin
the direct-call branch). It recovers the other 36, but it is wider than the regression: it also turns 223
long-standinguses/referencespairs intocalls. We checked all of them by AST and each one is a real
call site, so it looks correct, but it is a behavior change beyond 0.9.61. Leaving that decision to you.
Version: 0.9.62 → 0.9.70 (last good: 0.9.61) · OS: macOS · Python: 3.11 · Install: uv
(clean fixture, no LLM backend)
Additional context: introduced alongside #3156 (0.9.62). Not covered by #3405 or #2447.
Activity
github-actions commentedon Sep 28, 2026
Thanks for opening this issue, @wpoPR. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
JensD-git commentedon Sep 28, 2026
C# is affected by the same regression. For C#, the shape-A line suggested above should not be merged on its own. It recovers the lost constructor edges, but it also brings back almost as many wrong ones: in one C# code base, 202 recovered
new X()edges against 187 new edges fromnew X()to an enum member or property that merely shares the nameX. A small guard (diff below) keeps the recovery and removes almost all of those member bindings, including most of the ones 0.9.70 already has (359 → 14). Details and numbers below.Repro (C#, four files, nothing else needed)
Lib/Widget.csLib/Kinds.csApp/Factory.csApp/Plain.cs(control:Widgetis not used as a type in this file)graphify extract src --code-only, then thecalls/referencesedges leaving the four methods:MakeAis shape A:Widgetappears as a type argument of a field elsewhere in the same file, sonew Widget()binds to the sourceless stub and is dropped.Plain.Make()is the control and keeps its edge on every version.MakeBis shape B (the return type isWidget).Listin theMakeListrows is notSystem.Collections.Generic.List<T>. It is the enum memberViewKind.List(nodelib_kinds_demo_viewkind_list, the target of acase_ofedge). 0.9.61 had this wrong binding; since 0.9.62 it is gone, because the call is dropped along with the stub. The suggested line restores shape A and restores this wrong binding. The guard below keeps the first and prevents the second.The guard, as a unified diff against the 0.9.70 release. It contains the suggested shape-A line plus two small additions: tag a C# object creation in its raw call, and in the shared cross-file pass drop candidates that are the target of a
case_ofordefinesedge. That is the same kind of exclusion #3815 added to the C# type-definition index in 0.9.68.Size in one real C# code base (about 2,300
.csfiles). Unpatched releases, same source tree, rawgraph.json, counted as distinct (caller, target) pairs. Every counted site was matched against its source line (new <Name>at the reported line):new X()→ class defined in the corpus,callsreferencesonly (shape B)new X()→ enum member or property with the same name asXnew X()sites that had no edge in 0.9.61 either, but adds 187 wrong member pairs compared with 0.9.70. 143 of the 187 existed in 0.9.61 and disappeared in 0.9.62 (also measured on 0.9.62), so the line brings back the part of an older mis-binding that the fix(extract): skip calls to sourceless stubs #3531 change had removed as a side effect. In 156 of the 187 the name belongs only to a framework type (new List<T>()and the like); the corpus uses it for an enum member or a property but has no class of that name.callspair it removes is one of them. It also adds 139new X()→ class pairs, where a class shared its name with a member and was therefore an ambiguous candidate before. The 14 member pairs left are all bound within a single file, i.e. by the in-file lookup, which the guard does not touch.callspairs removed (all of them member bindings), 412 added (409new X()→ class, 3 method calls). For 38 of the 409 the corpus has more than one class of that name; we did not check whether the existing tie-breaker picked the right one.Request for C#: please let the shape-A change land only together with a guard like this. Without it, a C# graph trades one error for another. We have not run the test suite with the guard.
Measured on 0.9.61, 0.9.62 and 0.9.70 (latest release), Windows 11, Python 3.14, installed with uv,
--code-only, no LLM backend.fix(extract): keep constructor calls that hit a same-file annotation …
Merge upstream v8 into fix-3350-python-recursive-calls