Skip to content

Commit fea3528

Browse files
committed
fix: avoid self-loops when repointing bare imports
1 parent 55ca850 commit fea3528

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

graphify/extract.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ def _repoint_python_package_imports(paths, all_nodes, all_edges, root) -> None:
287287
elif stem_to_file_nodes and tgt in stem_to_file_nodes:
288288
candidates = stem_to_file_nodes[tgt]
289289
if len(candidates) == 1:
290-
e["target"] = next(iter(candidates))
290+
cand = next(iter(candidates))
291+
if cand != e.get("source"):
292+
e["target"] = cand
291293

292294

293295
SEMANTIC_RELATIONS = frozenset({

0 commit comments

Comments
 (0)