22# Distributed under the terms of the Modified BSD License.
33
44import copy
5+ from collections .abc import Callable
56from functools import partial
6- from typing import Any , Callable , Dict , List , Optional
7+ from typing import Any
78from uuid import uuid4
89
910from pycrdt import Array , Awareness , Doc , Map , Text
@@ -47,7 +48,7 @@ class YNotebook(YBaseDoc):
4748 }
4849 """
4950
50- def __init__ (self , ydoc : Optional [ Doc ] = None , awareness : Optional [ Awareness ] = None ):
51+ def __init__ (self , ydoc : Doc | None = None , awareness : Awareness | None = None ):
5152 """
5253 Constructs a YNotebook.
5354
@@ -92,7 +93,7 @@ def cell_number(self) -> int:
9293 """
9394 return len (self ._ycells )
9495
95- def get_cell (self , index : int ) -> Dict [str , Any ]:
96+ def get_cell (self , index : int ) -> dict [str , Any ]:
9697 """
9798 Returns a cell.
9899
@@ -104,7 +105,7 @@ def get_cell(self, index: int) -> Dict[str, Any]:
104105 """
105106 return self ._cell_to_py (self ._ycells [index ])
106107
107- def _cell_to_py (self , ycell : Map ) -> Dict [str , Any ]:
108+ def _cell_to_py (self , ycell : Map ) -> dict [str , Any ]:
108109 meta = self ._ymeta .to_py ()
109110 cell = ycell .to_py ()
110111 cell .pop ("execution_state" , None )
@@ -120,7 +121,7 @@ def _cell_to_py(self, ycell: Map) -> Dict[str, Any]:
120121 del cell ["attachments" ]
121122 return cell
122123
123- def append_cell (self , value : Dict [str , Any ]) -> None :
124+ def append_cell (self , value : dict [str , Any ]) -> None :
124125 """
125126 Appends a cell.
126127
@@ -130,7 +131,7 @@ def append_cell(self, value: Dict[str, Any]) -> None:
130131 ycell = self .create_ycell (value )
131132 self ._ycells .append (ycell )
132133
133- def set_cell (self , index : int , value : Dict [str , Any ]) -> None :
134+ def set_cell (self , index : int , value : dict [str , Any ]) -> None :
134135 """
135136 Sets a cell into indicated position.
136137
@@ -143,7 +144,7 @@ def set_cell(self, index: int, value: Dict[str, Any]) -> None:
143144 ycell = self .create_ycell (value )
144145 self .set_ycell (index , ycell )
145146
146- def create_ycell (self , value : Dict [str , Any ]) -> Map :
147+ def create_ycell (self , value : dict [str , Any ]) -> Map :
147148 """
148149 Creates YMap with the content of the cell.
149150
@@ -193,7 +194,7 @@ def set_ycell(self, index: int, ycell: Map) -> None:
193194 """
194195 self ._ycells [index ] = ycell
195196
196- def get (self ) -> Dict :
197+ def get (self ) -> dict :
197198 """
198199 Returns the content of the document.
199200
@@ -227,7 +228,7 @@ def get(self) -> Dict:
227228 nbformat_minor = int (meta .get ("nbformat_minor" , 0 )),
228229 )
229230
230- def set (self , value : Dict ) -> None :
231+ def set (self , value : dict ) -> None :
231232 """
232233 Sets the content of the document.
233234
@@ -251,7 +252,7 @@ def set(self, value: Dict) -> None:
251252 old_ycells_by_id = {ycell ["id" ]: ycell for ycell in self ._ycells }
252253
253254 with self ._ydoc .transaction ():
254- new_cell_list : List [dict ] = []
255+ new_cell_list : list [dict ] = []
255256 retained_cells = set ()
256257
257258 # Determine cells to be retained
0 commit comments