Skip to content

Commit 225237b

Browse files
committed
Type casting not needed now
1 parent f31aafc commit 225237b

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/neo4j_graphrag/experimental/pipeline/pipeline.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import warnings
1919
from collections import defaultdict
2020
from timeit import default_timer
21-
from typing import Any, Optional, AsyncGenerator, cast
21+
from typing import Any, Optional, AsyncGenerator
2222
import asyncio
2323

2424
from neo4j_graphrag.utils.logging import prettify
@@ -242,8 +242,7 @@ def _get_neo4j_viz_graph(
242242
size=20,
243243
properties={"node_type": "component"},
244244
)
245-
# Cast the node to Any before adding it to the list
246-
nodes.append(cast(Any, viz_node))
245+
nodes.append(viz_node)
247246
next_id += 1
248247

249248
# Create nodes for each output field
@@ -275,11 +274,10 @@ def _get_neo4j_viz_graph(
275274
size=15,
276275
properties={"node_type": "output"},
277276
)
278-
# Cast the node to Any before adding it to the list
279-
nodes.append(cast(Any, output_node))
277+
nodes.append(output_node)
280278

281279
# Connect component to its output
282-
# Add type ignore comment to suppress mypy errors
280+
# Connect component to its output
283281
rel = Relationship( # type: ignore
284282
source=node_ids[n],
285283
target=node_ids[param_node_name],
@@ -300,7 +298,6 @@ def _get_neo4j_viz_graph(
300298
source_output_node = source_component
301299

302300
if source_output_node in node_ids and component_name in node_ids:
303-
# Add type ignore comment to suppress mypy errors
304301
rel = Relationship( # type: ignore
305302
source=node_ids[source_output_node],
306303
target=node_ids[component_name],
@@ -309,12 +306,9 @@ def _get_neo4j_viz_graph(
309306
)
310307
relationships.append(rel)
311308

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
318312

319313
def get_pygraphviz_graph(self, hide_unused_outputs: bool = True) -> Any:
320314
"""Legacy method for backward compatibility.

0 commit comments

Comments
 (0)