From 8a982879264e7df75719d2f32057acd6b49b169c Mon Sep 17 00:00:00 2001 From: Huanyi Xie <74809554+xiehuanyi@users.noreply.github.com> Date: Mon, 5 Oct 2026 13:05:28 +0300 Subject: [PATCH] fix(extract): keep cross-drive diagnostic paths from aborting extraction Assisted-by: OpenAI Codex (GPT-6) --- graphify/extract.py | 6 +++++- tests/test_partial_extraction_warning.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/graphify/extract.py b/graphify/extract.py index b463ae388..40c0c72b3 100644 --- a/graphify/extract.py +++ b/graphify/extract.py @@ -7790,7 +7790,11 @@ def extract( continue # empty / whitespace-only: nothing to model, no signal except OSError: _size = 0 - _symbolless_files.append((os.path.relpath(str(_p), str(root)).replace("\\", "/"), _size)) + try: + _display_path = os.path.relpath(str(_p), str(root)).replace("\\", "/") + except ValueError: + _display_path = _p.as_posix() + _symbolless_files.append((_display_path, _size)) if _symbolless_files: _total_bytes = sum(size for _, size in _symbolless_files) _total_mb = _total_bytes / (1024 * 1024) diff --git a/tests/test_partial_extraction_warning.py b/tests/test_partial_extraction_warning.py index eb1ada0eb..f859bcd8a 100644 --- a/tests/test_partial_extraction_warning.py +++ b/tests/test_partial_extraction_warning.py @@ -102,6 +102,25 @@ def test_symbolless_warning_names_the_file(tmp_path, capsys): assert "may be data rather than code" not in err +def test_symbolless_warning_survives_a_cross_drive_path(tmp_path, capsys, monkeypatch): + import graphify.extract as ex + + source = _data_only_fixture(tmp_path) + original_relpath = ex.os.path.relpath + + def cross_drive_relpath(path, start=None): + if str(path) == str(source) and str(start) == str(tmp_path): + raise ValueError("path is on mount 'D:', start on mount 'C:'") + return original_relpath(path, start) + + monkeypatch.setattr(ex.os.path, "relpath", cross_drive_relpath) + result = extract([source], root=tmp_path) + assert any(node.get("label") == "data.js" for node in result["nodes"]) + err = capsys.readouterr().err + assert "yielded no symbols" in err + assert source.as_posix() in err + + def test_symbolless_warning_is_silent_for_an_empty_init(tmp_path, capsys): """An empty __init__.py is symbol-less *code*, ubiquitous in Python packages. It has nothing to model, so the warning must stay silent rather