From fcfc2d1fcd83d7c7c62b45adb346df9d22b10be7 Mon Sep 17 00:00:00 2001 From: SinghAman21 Date: Mon, 13 Jul 2026 23:19:22 +0530 Subject: [PATCH] fix(dedup): correct id-collision warning and prefer defining file --- graphify/dedup.py | 105 +++++++++++++++++++++++++++++++++++++------- tests/test_dedup.py | 61 +++++++++++++++++++++---- 2 files changed, 141 insertions(+), 25 deletions(-) diff --git a/graphify/dedup.py b/graphify/dedup.py index e0ddd2e3b..4dc099e85 100644 --- a/graphify/dedup.py +++ b/graphify/dedup.py @@ -9,8 +9,10 @@ import sys import unicodedata from collections import defaultdict +from pathlib import Path from graphify._minhash import MinHash, MinHashLSH +from graphify.ids import make_id, normalize_id from rapidfuzz.distance import Jaro, JaroWinkler @@ -187,6 +189,42 @@ def _is_code(node: dict) -> bool: return node.get("file_type") == "code" +def _node_defines_id(node: dict, nid: str) -> bool: + """True when ``node``'s own ``source_file`` is the file encoded in ``nid``. + + Non-AST node ids are ``make_id(_file_stem(source_file),