Skip to content

Commit e80f754

Browse files
authored
Merge pull request #32 from codefuse-ai:fix-str-path
fix DependencyGraph file_path issue when it is str
2 parents 4c908cc + 1633b9f commit e80f754

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

repo_specific_semantic_graph/dependency_graph/dependency_graph.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
import sys
33
from functools import lru_cache
44
from pathlib import Path
5-
from typing import Iterable, Callable, Optional, Tuple, List, Set
5+
from typing import Callable, Iterable, List, Optional, Set, Tuple
66

77
import networkx as nx
8-
98
from dependency_graph.models import PathLike, VirtualPath
10-
from dependency_graph.models.graph_data import Node, Edge, EdgeRelation, NodeType
9+
from dependency_graph.models.graph_data import Edge, EdgeRelation, Node, NodeType
1110
from dependency_graph.models.language import Language
1211
from dependency_graph.utils.digraph import lexicographical_cyclic_topological_sort
1312
from dependency_graph.utils.intervals import find_innermost_interval
@@ -236,6 +235,7 @@ def get_related_edges_by_innermost_node_between_line(
236235
start_line: int,
237236
*relations: EdgeRelation,
238237
) -> Optional[List[Tuple[Node, Node, Edge]]]:
238+
file_path = self._Path(file_path)
239239
node = self._get_innermost_node_by_line(file_path, start_line)
240240
related_edge_list = self.graph.get_related_edges_by_node(
241241
node,
@@ -270,6 +270,7 @@ def get_cross_file_context(
270270
- The in node should be located in the repo and be cross-file
271271
- The out node should be in the same file
272272
"""
273+
file_path = self._Path(file_path)
273274
# Don't feel guilty, self.graph.get_edges is cached!
274275
edge_list = self.graph.get_edges(
275276
edge_filter=lambda in_node, out_node, edge: self.is_node_from_cross_file(
@@ -296,6 +297,7 @@ def get_cross_file_definition_by_line(
296297
It will return the cross-file definition of the innermost scope(func/class) located between the start_line.
297298
Usually it is the out-node we are interested in.
298299
"""
300+
file_path = self._Path(file_path)
299301
edge_list = []
300302

301303
related_edge_list = self.get_related_edges_by_innermost_node_between_line(
@@ -360,6 +362,7 @@ def get_cross_file_reference_by_line(
360362
It will return the cross-file usage of the innermost scope(func/class) located between the start_line.
361363
Usually it is the out-node we are interested in.
362364
"""
365+
file_path = self._Path(file_path)
363366
related_edge_list = self.get_related_edges_by_innermost_node_between_line(
364367
file_path,
365368
start_line,
@@ -392,6 +395,7 @@ def get_related_edges_by_file(
392395
"""
393396
Get all related edges of a file and return them
394397
"""
398+
file_path = self._Path(file_path)
395399
return self.graph.get_edges(
396400
edge_filter=lambda in_node, out_node, edge: self.is_node_from_in_file(
397401
in_node, file_path

0 commit comments

Comments
 (0)