18
18
import warnings
19
19
from collections import defaultdict
20
20
from timeit import default_timer
21
- from typing import Any , Optional , AsyncGenerator , cast
21
+ from typing import Any , Optional , AsyncGenerator
22
22
import asyncio
23
23
24
24
from neo4j_graphrag .utils .logging import prettify
@@ -242,8 +242,7 @@ def _get_neo4j_viz_graph(
242
242
size = 20 ,
243
243
properties = {"node_type" : "component" },
244
244
)
245
- # Cast the node to Any before adding it to the list
246
- nodes .append (cast (Any , viz_node ))
245
+ nodes .append (viz_node )
247
246
next_id += 1
248
247
249
248
# Create nodes for each output field
@@ -275,11 +274,10 @@ def _get_neo4j_viz_graph(
275
274
size = 15 ,
276
275
properties = {"node_type" : "output" },
277
276
)
278
- # Cast the node to Any before adding it to the list
279
- nodes .append (cast (Any , output_node ))
277
+ nodes .append (output_node )
280
278
281
279
# Connect component to its output
282
- # Add type ignore comment to suppress mypy errors
280
+ # Connect component to its output
283
281
rel = Relationship ( # type: ignore
284
282
source = node_ids [n ],
285
283
target = node_ids [param_node_name ],
@@ -300,7 +298,6 @@ def _get_neo4j_viz_graph(
300
298
source_output_node = source_component
301
299
302
300
if source_output_node in node_ids and component_name in node_ids :
303
- # Add type ignore comment to suppress mypy errors
304
301
rel = Relationship ( # type: ignore
305
302
source = node_ids [source_output_node ],
306
303
target = node_ids [component_name ],
@@ -309,12 +306,9 @@ def _get_neo4j_viz_graph(
309
306
)
310
307
relationships .append (rel )
311
308
312
- # Cast the constructor to Any, then cast the result back to VisualizationGraph
313
- viz_graph = cast (Any , VisualizationGraph )(
314
- nodes = nodes , relationships = relationships
315
- )
316
- # Cast the result back to the expected return type
317
- return cast (VisualizationGraph , viz_graph )
309
+ # Create the visualization graph
310
+ viz_graph = VisualizationGraph (nodes = nodes , relationships = relationships )
311
+ return viz_graph
318
312
319
313
def get_pygraphviz_graph (self , hide_unused_outputs : bool = True ) -> Any :
320
314
"""Legacy method for backward compatibility.
0 commit comments