1
1
from functools import reduce
2
- from typing import Any , Dict , List , Type , Union
2
+ from typing import Any , Type , Union
3
3
from warnings import filterwarnings
4
4
5
5
import pandas as pd
18
18
from .graph_object import Graph
19
19
from .graph_type_check import graph_type_check
20
20
21
- Strings = Union [str , List [str ]]
21
+ Strings = Union [str , list [str ]]
22
22
23
23
24
24
class TopologyDataFrame (DataFrame ):
25
25
@property
26
26
def _constructor (self ) -> "Type[TopologyDataFrame]" :
27
27
return TopologyDataFrame
28
28
29
- def by_rel_type (self ) -> Dict [str , List [ List [int ]]]:
29
+ def by_rel_type (self ) -> dict [str , list [ list [int ]]]:
30
30
# Pandas 2.2.0 deprecated an internal API used by DF.take(indices)
31
31
filterwarnings (
32
32
"ignore" ,
@@ -55,7 +55,7 @@ def _handle_properties(
55
55
G : Graph ,
56
56
properties : Strings ,
57
57
entities : Strings ,
58
- config : Dict [str , Any ],
58
+ config : dict [str , Any ],
59
59
) -> DataFrame :
60
60
params = CallParameters (
61
61
graph_name = G .name (),
@@ -78,7 +78,7 @@ def stream(
78
78
G : Graph ,
79
79
node_property : str ,
80
80
node_labels : Strings = ["*" ],
81
- db_node_properties : List [str ] = [],
81
+ db_node_properties : list [str ] = [],
82
82
** config : Any ,
83
83
) -> DataFrame :
84
84
self ._namespace += ".stream"
@@ -96,10 +96,10 @@ class GraphNodePropertiesRunner(GraphEntityOpsBaseRunner):
96
96
def stream (
97
97
self ,
98
98
G : Graph ,
99
- node_properties : List [str ],
99
+ node_properties : list [str ],
100
100
node_labels : Strings = ["*" ],
101
101
separate_property_columns : bool = False ,
102
- db_node_properties : List [str ] = [],
102
+ db_node_properties : list [str ] = [],
103
103
** config : Any ,
104
104
) -> DataFrame :
105
105
self ._namespace += ".stream"
@@ -113,11 +113,11 @@ def stream(
113
113
@staticmethod
114
114
def _process_result (
115
115
query_runner : QueryRunner ,
116
- node_properties : List [str ],
116
+ node_properties : list [str ],
117
117
separate_property_columns : bool ,
118
- db_node_properties : List [str ],
118
+ db_node_properties : list [str ],
119
119
result : DataFrame ,
120
- config : Dict [str , Any ],
120
+ config : dict [str , Any ],
121
121
) -> DataFrame :
122
122
# new format was requested, but the query was run via Cypher
123
123
if separate_property_columns and "propertyValue" in result .keys ():
@@ -161,7 +161,7 @@ def _process_result(
161
161
return result
162
162
163
163
@staticmethod
164
- def _build_query (db_node_properties : List [str ]) -> str :
164
+ def _build_query (db_node_properties : list [str ]) -> str :
165
165
query_prefix = "MATCH (n) WHERE id(n) IN $ids RETURN id(n) AS nodeId"
166
166
167
167
def add_property (query : str , prop : str ) -> str :
@@ -176,7 +176,7 @@ def write(self, G: Graph, node_properties: Strings, node_labels: Strings = ["*"]
176
176
177
177
@compatible_with ("drop" , min_inclusive = ServerVersion (2 , 2 , 0 ))
178
178
@graph_type_check
179
- def drop (self , G : Graph , node_properties : List [str ], ** config : Any ) -> "Series[Any]" :
179
+ def drop (self , G : Graph , node_properties : list [str ], ** config : Any ) -> "Series[Any]" :
180
180
self ._namespace += ".drop"
181
181
params = CallParameters (
182
182
graph_name = G .name (),
@@ -205,7 +205,7 @@ class GraphRelationshipPropertiesRunner(GraphEntityOpsBaseRunner):
205
205
def stream (
206
206
self ,
207
207
G : Graph ,
208
- relationship_properties : List [str ],
208
+ relationship_properties : list [str ],
209
209
relationship_types : Strings = ["*" ],
210
210
separate_property_columns : bool = False ,
211
211
** config : Any ,
@@ -239,7 +239,7 @@ def write(
239
239
self ,
240
240
G : Graph ,
241
241
relationship_type : str ,
242
- relationship_properties : List [str ],
242
+ relationship_properties : list [str ],
243
243
** config : Any ,
244
244
) -> "Series[Any]" :
245
245
self ._namespace += ".write"
@@ -319,7 +319,7 @@ def drop(
319
319
320
320
@compatible_with ("stream" , min_inclusive = ServerVersion (2 , 5 , 0 ))
321
321
@graph_type_check
322
- def stream (self , G : Graph , relationship_types : List [str ] = ["*" ], ** config : Any ) -> TopologyDataFrame :
322
+ def stream (self , G : Graph , relationship_types : list [str ] = ["*" ], ** config : Any ) -> TopologyDataFrame :
323
323
self ._namespace += ".stream"
324
324
params = CallParameters (graph_name = G .name (), relationship_types = relationship_types , config = config )
325
325
result = self ._query_runner .call_procedure (endpoint = self ._namespace , params = params )
@@ -336,7 +336,7 @@ def toUndirected(self) -> ToUndirectedRunner:
336
336
class GraphRelationshipsBetaRunner (GraphEntityOpsBaseRunner ):
337
337
@compatible_with ("stream" , min_inclusive = ServerVersion (2 , 2 , 0 ))
338
338
@graph_type_check
339
- def stream (self , G : Graph , relationship_types : List [str ] = ["*" ], ** config : Any ) -> TopologyDataFrame :
339
+ def stream (self , G : Graph , relationship_types : list [str ] = ["*" ], ** config : Any ) -> TopologyDataFrame :
340
340
self ._namespace += ".stream"
341
341
params = CallParameters (graph_name = G .name (), relationship_types = relationship_types , config = config )
342
342
0 commit comments