@@ -253,7 +253,7 @@ def set(self, value: Dict) -> None:
253253
254254 with self ._ydoc .transaction ():
255255 try :
256- new_cell_list : List [tuple [ Map , dict ] ] = []
256+ new_cell_list : List [dict ] = []
257257 retained_cells = set ()
258258
259259 # Determine cells to be retained
@@ -262,11 +262,11 @@ def set(self, value: Dict) -> None:
262262 if cell_id and (old_ycell := old_ycells_by_id .get (cell_id )):
263263 old_cell = self ._cell_to_py (old_ycell )
264264 if old_cell == new_cell :
265- new_cell_list .append (( old_ycell , old_cell ) )
265+ new_cell_list .append (old_cell )
266266 retained_cells .add (cell_id )
267267 continue
268268 # New or changed cell
269- new_cell_list .append (( self . create_ycell ( new_cell ), new_cell ) )
269+ new_cell_list .append (new_cell )
270270
271271 # First delete all non-retained cells
272272 if not retained_cells :
@@ -282,23 +282,20 @@ def set(self, value: Dict) -> None:
282282
283283 # Now add new cells
284284 index = 0
285- for new_ycell , new_cell in new_cell_list :
285+ for new_cell in new_cell_list :
286286 if len (self ._ycells ) > index :
287- # we need to compare against a python cell to avoid
288- # an extra transaction on new cells which are not yet
289- # integrated into the ydoc document.
290287 if self ._ycells [index ]["id" ] == new_cell .get ("id" ):
291288 # retained cell
292289 index += 1
293290 continue
294- self ._ycells .insert (index , new_ycell )
291+ self ._ycells .insert (index , self . create_ycell ( new_cell ) )
295292 index += 1
296293
297294 except Exception as e :
298295 # Fallback to total overwrite, warn to allow debugging
299296 warn (f"All cells were reloaded due to an error in granular reload logic: { e } " )
300297 self ._ycells .clear ()
301- self ._ycells .extend ([new_ycell for ( new_ycell , _new_cell ) in new_cell_list ])
298+ self ._ycells .extend ([self . create_ycell ( new_cell ) for new_cell in new_cell_list ])
302299
303300 for key in [
304301 k for k in self ._ystate .keys () if k not in ("dirty" , "path" , "document_id" )
0 commit comments