1010import inspect
1111import typing
1212from abc import ABC , ABCMeta , abstractmethod
13- from collections .abc import Callable , Iterator , Mapping , Sequence
13+ from collections .abc import Callable , Iterable , Iterator , Mapping , Sequence
1414from dataclasses import _MISSING_TYPE , MISSING
1515from functools import wraps
1616from hashlib import md5
@@ -374,15 +374,15 @@ def _get_all_dynamic_imports(self) -> set[str]:
374374 """
375375
376376 @abstractmethod
377- def _get_all_custom_code (self ) -> set [str ]:
377+ def _get_all_custom_code (self ) -> dict [str , None ]:
378378 """Get custom code for the component.
379379
380380 Returns:
381381 The custom code.
382382 """
383383
384384 @abstractmethod
385- def _get_all_refs (self ) -> set [str ]:
385+ def _get_all_refs (self ) -> dict [str , None ]:
386386 """Get the refs for the children of the component.
387387
388388 Returns:
@@ -1003,13 +1003,13 @@ def _render(self, props: dict[str, Any] | None = None) -> Tag:
10031003
10041004 @classmethod
10051005 @functools .cache
1006- def get_props (cls ) -> set [str ]:
1006+ def get_props (cls ) -> Iterable [str ]:
10071007 """Get the unique fields for the component.
10081008
10091009 Returns:
10101010 The unique fields.
10111011 """
1012- return set ( cls .get_js_fields () )
1012+ return cls .get_js_fields ()
10131013
10141014 @classmethod
10151015 @functools .cache
@@ -1509,27 +1509,27 @@ def _get_custom_code(self) -> str | None:
15091509 """
15101510 return None
15111511
1512- def _get_all_custom_code (self ) -> set [str ]:
1512+ def _get_all_custom_code (self ) -> dict [str , None ]:
15131513 """Get custom code for the component and its children.
15141514
15151515 Returns:
15161516 The custom code.
15171517 """
15181518 # Store the code in a set to avoid duplicates.
1519- code = set ()
1519+ code : dict [ str , None ] = {}
15201520
15211521 # Add the custom code for this component.
15221522 custom_code = self ._get_custom_code ()
15231523 if custom_code is not None :
1524- code . add ( custom_code )
1524+ code [ custom_code ] = None
15251525
15261526 for component in self ._get_components_in_props ():
15271527 code |= component ._get_all_custom_code ()
15281528
15291529 # Add the custom code from add_custom_code method.
15301530 for clz in self ._iter_parent_classes_with_method ("add_custom_code" ):
15311531 for item in clz .add_custom_code (self ):
1532- code . add ( item )
1532+ code [ item ] = None
15331533
15341534 # Add the custom code for the children.
15351535 for child in self .children :
@@ -1814,7 +1814,7 @@ def _get_all_hooks_internal(self) -> dict[str, VarData | None]:
18141814
18151815 # Add the hook code for the children.
18161816 for child in self .children :
1817- code = { ** code , ** child ._get_all_hooks_internal ()}
1817+ code . update ( child ._get_all_hooks_internal ())
18181818
18191819 return code
18201820
@@ -1838,7 +1838,7 @@ def _get_all_hooks(self) -> dict[str, VarData | None]:
18381838
18391839 # Add the hook code for the children.
18401840 for child in self .children :
1841- code = { ** code , ** child ._get_all_hooks ()}
1841+ code . update ( child ._get_all_hooks ())
18421842
18431843 return code
18441844
@@ -1853,16 +1853,16 @@ def get_ref(self) -> str | None:
18531853 return None
18541854 return format .format_ref (self .id )
18551855
1856- def _get_all_refs (self ) -> set [str ]:
1856+ def _get_all_refs (self ) -> dict [str , None ]:
18571857 """Get the refs for the children of the component.
18581858
18591859 Returns:
18601860 The refs for the children.
18611861 """
1862- refs = set ()
1862+ refs = {}
18631863 ref = self .get_ref ()
18641864 if ref is not None :
1865- refs . add ( ref )
1865+ refs [ ref ] = None
18661866 for child in self .children :
18671867 refs |= child ._get_all_refs ()
18681868 for component in self ._get_components_in_props ():
@@ -1994,7 +1994,7 @@ def get_args_spec(key: str) -> types.ArgsSpec | Sequence[types.ArgsSpec]:
19941994 )
19951995
19961996 to_camel_cased_props = {
1997- format .to_camel_case (key + MEMO_MARKER )
1997+ format .to_camel_case (key + MEMO_MARKER ): None
19981998 for key in props
19991999 if key not in event_types
20002000 }
@@ -2048,13 +2048,13 @@ def __hash__(self) -> int:
20482048 return hash (self .tag )
20492049
20502050 @classmethod
2051- def get_props (cls ) -> set [str ]:
2051+ def get_props (cls ) -> Iterable [str ]:
20522052 """Get the props for the component.
20532053
20542054 Returns:
20552055 The set of component props.
20562056 """
2057- return set ()
2057+ return ()
20582058
20592059 @staticmethod
20602060 def _get_event_spec_from_args_spec (name : str , event : EventChain ) -> Callable :
@@ -2656,7 +2656,7 @@ def _get_all_dynamic_imports(self) -> set[str]:
26562656 return set ()
26572657 return self .component ._get_all_dynamic_imports ()
26582658
2659- def _get_all_custom_code (self , export : bool = False ) -> set [str ]:
2659+ def _get_all_custom_code (self , export : bool = False ) -> dict [str , None ]:
26602660 """Get custom code for the component.
26612661
26622662 Args:
@@ -2666,19 +2666,19 @@ def _get_all_custom_code(self, export: bool = False) -> set[str]:
26662666 The custom code.
26672667 """
26682668 if self .rendered_as_shared :
2669- return set ()
2670- return self .component ._get_all_custom_code (). union (
2671- {self ._render_stateful_code (export = export )}
2669+ return {}
2670+ return self .component ._get_all_custom_code () | (
2671+ {self ._render_stateful_code (export = export ): None }
26722672 )
26732673
2674- def _get_all_refs (self ) -> set [str ]:
2674+ def _get_all_refs (self ) -> dict [str , None ]:
26752675 """Get the refs for the children of the component.
26762676
26772677 Returns:
26782678 The refs for the children.
26792679 """
26802680 if self .rendered_as_shared :
2681- return set ()
2681+ return {}
26822682 return self .component ._get_all_refs ()
26832683
26842684 def render (self ) -> dict :
0 commit comments