@@ -450,6 +450,33 @@ async def get(self) -> AbstractComponent:
450
450
return component
451
451
452
452
453
+ def _process_child_type_and_key (
454
+ children : List [Any ],
455
+ ) -> Iterator [Tuple [Any , int , Any ]]:
456
+ for child in children :
457
+ if isinstance (child , dict ):
458
+ child_type = _DICT_TYPE
459
+ key = child .get ("key" )
460
+ elif isinstance (child , AbstractComponent ):
461
+ child_type = _COMPONENT_TYPE
462
+ key = getattr (child , "key" , None )
463
+ else :
464
+ child = f"{ child } "
465
+ child_type = _STRING_TYPE
466
+ key = None
467
+
468
+ if key is None :
469
+ key = object ()
470
+
471
+ yield (child , child_type , key )
472
+
473
+
474
+ # used in _process_child_type_and_key
475
+ _DICT_TYPE = 1
476
+ _COMPONENT_TYPE = 2
477
+ _STRING_TYPE = 3
478
+
479
+
453
480
class _ModelEventTarget (TypedDict ):
454
481
target : str
455
482
preventDefault : bool # noqa
@@ -475,30 +502,3 @@ class _ModelVdomRequired(TypedDict, total=True):
475
502
476
503
class _ModelVdom (_ModelVdomRequired , _ModelVdomOptional ):
477
504
"""A VDOM dictionary model specifically for use with a :class:`Layout`"""
478
-
479
-
480
- def _process_child_type_and_key (
481
- raw_children : List [Any ],
482
- ) -> Iterator [Tuple [Any , int , Any ]]:
483
- for index , child in enumerate (raw_children ):
484
- if isinstance (child , dict ):
485
- child_type = _DICT_TYPE
486
- key = child .get ("key" )
487
- elif isinstance (child , AbstractComponent ):
488
- child_type = _COMPONENT_TYPE
489
- key = getattr (child , "key" , None )
490
- else :
491
- child = f"{ child } "
492
- child_type = _STRING_TYPE
493
- key = None
494
-
495
- if key is None :
496
- key = index
497
-
498
- yield (child , child_type , key )
499
-
500
-
501
- # used in _process_child_type_and_key
502
- _DICT_TYPE = 1
503
- _COMPONENT_TYPE = 2
504
- _STRING_TYPE = 3
0 commit comments