From 5a6d267da17150a96229e923dcde5b460a6a1171 Mon Sep 17 00:00:00 2001 From: YogeLiu <56834120+YogeLiu@users.noreply.github.com> Date: Wed, 12 Aug 2026 15:20:22 +0000 Subject: [PATCH] fix(graph): correct delete_files return contract --- api/graph.py | 6 ++++-- tests/test_graph_delete_files.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/test_graph_delete_files.py diff --git a/api/graph.py b/api/graph.py index ffa208fb..6f179007 100644 --- a/api/graph.py +++ b/api/graph.py @@ -520,13 +520,16 @@ def add_file(self, file: File) -> None: node = res.result_set[0][0] file.id = node.id - def delete_files(self, files: list[Path]) -> tuple[str, dict, list[int]]: + def delete_files(self, files: list[Path]) -> None: """ Deletes file(s) from the graph in addition to any other entity defined in the file a file is defined by its path, name and extension files = [{'path':_, 'name': _, 'ext': _}, ...] + + Returns: + None """ q = """UNWIND $files AS file @@ -538,7 +541,6 @@ def delete_files(self, files: list[Path]) -> tuple[str, dict, list[int]]: params = {'files': [{'path': str(file_path), 'name': file_path.name, 'ext' : file_path.suffix} for file_path in files]} self._query(q, params) - return None def get_file(self, path: str, name: str, ext: str) -> Optional[Node]: """ diff --git a/tests/test_graph_delete_files.py b/tests/test_graph_delete_files.py new file mode 100644 index 00000000..7a570d8c --- /dev/null +++ b/tests/test_graph_delete_files.py @@ -0,0 +1,16 @@ +from inspect import signature +from pathlib import Path +from unittest.mock import Mock + +from api.graph import Graph + + +def test_delete_files_return_contract() -> None: + graph = Graph.__new__(Graph) + graph._query = Mock() + + result = graph.delete_files([Path("src/example.py")]) + + assert result is None + assert signature(Graph.delete_files).return_annotation is None + graph._query.assert_called_once()