11from pathlib import Path
2- from typing import Any , Callable , Tuple , Optional , Dict , Union , Set
2+ from typing import Any , Callable , Tuple , Optional , Dict , Union , Set , cast
33
44from typing_extensions import Protocol
55
@@ -183,7 +183,7 @@ async def HotSwap() -> Any:
183183 # new displays will adopt the latest constructor and arguments
184184 (f , a , kw ), set_state = hooks .use_state (constructor_and_arguments .current )
185185
186- def add_callback ():
186+ def add_callback () -> Callable [[], None ] :
187187 set_state_callbacks .add (set_state )
188188 return lambda : set_state_callbacks .remove (set_state )
189189
@@ -210,7 +210,7 @@ def swap(_func_: ElementConstructor, *args: Any, **kwargs: Any) -> None:
210210 constructor_and_arguments .current = (_func_ , args , kwargs )
211211 return None
212212
213- return swap , HotSwap
213+ return cast ( MountFunc , swap ) , HotSwap
214214
215215
216216def multiview () -> Tuple ["MultiViewMount" , ElementConstructor ]:
@@ -290,36 +290,3 @@ def _add_view(
290290 kwargs : Dict [str , Any ],
291291 ) -> None :
292292 self ._views [view_id ] = lambda : constructor (* args , ** kwargs )
293-
294-
295- {
296- "tagName" : "div" ,
297- "children" : [
298- {
299- "tagName" : "div" ,
300- "children" : [
301- {
302- "tagName" : "button" ,
303- "attributes" : {"id" : "incr-button" },
304- "children" : ["click to increment" ],
305- "eventHandlers" : {
306- "onClick" : {
307- "target" : "139775953392160" ,
308- "preventDefault" : False ,
309- "stopPropagation" : False ,
310- }
311- },
312- },
313- {
314- "tagName" : "div" ,
315- "attributes" : {"id" : "count-is-1" },
316- "children" : ["1" ],
317- },
318- ],
319- }
320- ],
321- }
322- [
323- {"path" : "/children/1/attributes/id" , "op" : "replace" , "value" : "count-is-1" },
324- {"path" : "/children/1/children/0" , "op" : "replace" , "value" : "1" },
325- ]
0 commit comments