@@ -221,7 +221,8 @@ def update(self, attrs: Any) -> None:
221221 if not attrs :
222222 return
223223
224- self .data .update (build_node_attr_dict_data (self , attrs ))
224+ node_attr_dict_data = build_node_attr_dict_data (self , attrs )
225+ self .data .update (node_attr_dict_data )
225226
226227 if not self .node_id :
227228 logger .debug ("Node ID not set, skipping NodeAttrDict(?).update()" )
@@ -275,10 +276,12 @@ def __init__(
275276 self .FETCHED_ALL_DATA = False
276277 self .FETCHED_ALL_IDS = False
277278
278- def _create_node_attr_dict (self , vertex : dict [str , Any ]) -> NodeAttrDict :
279+ def _create_node_attr_dict (
280+ self , node_id : str , node_data : dict [str , Any ]
281+ ) -> NodeAttrDict :
279282 node_attr_dict = self .node_attr_dict_factory ()
280- node_attr_dict .node_id = vertex [ "_id" ]
281- node_attr_dict .data = build_node_attr_dict_data (node_attr_dict , vertex )
283+ node_attr_dict .node_id = node_id
284+ node_attr_dict .data = build_node_attr_dict_data (node_attr_dict , node_data )
282285
283286 return node_attr_dict
284287
@@ -322,7 +325,7 @@ def __getitem__(self, key: str) -> NodeAttrDict:
322325 raise KeyError (key )
323326
324327 if vertex_db := vertex_get (self .graph , node_id ):
325- node_attr_dict = self ._create_node_attr_dict (vertex_db )
328+ node_attr_dict = self ._create_node_attr_dict (vertex_db [ "_id" ], vertex_db )
326329 self .data [node_id ] = node_attr_dict
327330
328331 return node_attr_dict
@@ -342,7 +345,7 @@ def __setitem__(self, key: str, value: NodeAttrDict) -> None:
342345
343346 result = doc_insert (self .db , node_type , node_id , value .data )
344347
345- node_attr_dict = self ._create_node_attr_dict (result )
348+ node_attr_dict = self ._create_node_attr_dict (result [ "_id" ], value . data )
346349
347350 self .data [node_id ] = node_attr_dict
348351
@@ -405,10 +408,7 @@ def copy(self) -> Any:
405408 @keys_are_strings
406409 def __update_local_nodes (self , nodes : Any ) -> None :
407410 for node_id , node_data in nodes .items ():
408- node_attr_dict = self .node_attr_dict_factory ()
409- node_attr_dict .node_id = node_id
410- node_attr_dict .data = build_node_attr_dict_data (node_attr_dict , node_data )
411-
411+ node_attr_dict = self ._create_node_attr_dict (node_id , node_data )
412412 self .data [node_id ] = node_attr_dict
413413
414414 @keys_are_strings
@@ -478,7 +478,7 @@ def _fetch_all(self):
478478
479479 for node_id , node_data in node_dict .items ():
480480 del node_data ["_rev" ] # TODO: Optimize away via phenolrs
481- node_attr_dict = self ._create_node_attr_dict (node_data )
481+ node_attr_dict = self ._create_node_attr_dict (node_data [ "_id" ], node_data )
482482 self .data [node_id ] = node_attr_dict
483483
484484 self .FETCHED_ALL_DATA = True
0 commit comments