@@ -43,7 +43,7 @@ class State(NamedTuple, Generic[_Type]):
4343"""The root component should be constructed by a function accepting no arguments."""
4444
4545
46- Key : TypeAlias = " str | int"
46+ Key : TypeAlias = str | int
4747
4848
4949@runtime_checkable
@@ -98,16 +98,16 @@ async def __aexit__(
9898
9999# TODO: It's probably better to break this one attributes dict down into what each specific
100100# HTML node's attributes can be, and make sure those types are resolved correctly within `HtmlConstructor`
101- VdomAttributes = TypedDict (
102- "VdomAttributes " ,
101+ _VdomAttributes = TypedDict (
102+ "_VdomAttributes " ,
103103 {
104104 "key" : Key ,
105105 "value" : Any ,
106106 "defaultValue" : Any ,
107107 "dangerouslySetInnerHTML" : dict [str , str ],
108108 "suppressContentEditableWarning" : bool ,
109109 "suppressHydrationWarning" : bool ,
110- "style" : dict [str , str | int | float ],
110+ "style" : dict [str , Any ],
111111 "accessKey" : str ,
112112 "aria-" : None ,
113113 "autoCapitalize" : str ,
@@ -341,10 +341,12 @@ async def __aexit__(
341341 "onWaitingCapture" : EventFunc ,
342342 },
343343 total = False ,
344- # TODO: Enable this when Python 3.14 typing extensions are released
345344 # extra_items=Any,
346345)
347346
347+ # TODO: Enable `extra_items` when PEP 728 is merged, likely in Python 3.14. Ref: https://peps.python.org/pep-0728/
348+ VdomAttributes = _VdomAttributes | dict [str , Any ]
349+
348350
349351class VdomDict (TypedDict ):
350352 """A :ref:`VDOM` dictionary"""
@@ -357,10 +359,10 @@ class VdomDict(TypedDict):
357359 importSource : NotRequired [ImportSourceDict ]
358360
359361
360- VdomChild : TypeAlias = " ComponentType | VdomDict | str | None | Any"
362+ VdomChild : TypeAlias = ComponentType | VdomDict | str | None | Any
361363"""A single child element of a :class:`VdomDict`"""
362364
363- VdomChildren : TypeAlias = " Sequence[VdomChild] | VdomChild"
365+ VdomChildren : TypeAlias = Sequence [VdomChild ] | VdomChild
364366"""Describes a series of :class:`VdomChild` elements"""
365367
366368
@@ -371,41 +373,29 @@ class ImportSourceDict(TypedDict):
371373 unmountBeforeUpdate : bool
372374
373375
374- class _OptionalVdomJson (TypedDict , total = False ):
375- key : Key
376- error : str
377- children : list [Any ]
378- attributes : VdomAttributes
379- eventHandlers : dict [str , _JsonEventTarget ]
380- importSource : _JsonImportSource
381-
376+ class VdomJson (TypedDict ):
377+ """A JSON serializable form of :class:`VdomDict` matching the :data:`VDOM_JSON_SCHEMA`"""
382378
383- class _RequiredVdomJson (TypedDict , total = True ):
384379 tagName : str
380+ key : NotRequired [Key ]
381+ error : NotRequired [str ]
382+ children : NotRequired [list [Any ]]
383+ attributes : NotRequired [VdomAttributes ]
384+ eventHandlers : NotRequired [dict [str , JsonEventTarget ]]
385+ importSource : NotRequired [JsonImportSource ]
385386
386387
387- class VdomJson (_RequiredVdomJson , _OptionalVdomJson ):
388- """A JSON serializable form of :class:`VdomDict` matching the :data:`VDOM_JSON_SCHEMA`"""
389-
390-
391- class _JsonEventTarget (TypedDict ):
388+ class JsonEventTarget (TypedDict ):
392389 target : str
393390 preventDefault : bool
394391 stopPropagation : bool
395392
396393
397- class _JsonImportSource (TypedDict ):
394+ class JsonImportSource (TypedDict ):
398395 source : str
399396 fallback : Any
400397
401398
402- EventHandlerMapping = Mapping [str , "EventHandlerType" ]
403- """A generic mapping between event names to their handlers"""
404-
405- EventHandlerDict : TypeAlias = "dict[str, EventHandlerType]"
406- """A dict mapping between event names to their handlers"""
407-
408-
409399class EventHandlerFunc (Protocol ):
410400 """A coroutine which can handle event data"""
411401
@@ -437,6 +427,13 @@ class EventHandlerType(Protocol):
437427 """
438428
439429
430+ EventHandlerMapping = Mapping [str , EventHandlerType ]
431+ """A generic mapping between event names to their handlers"""
432+
433+ EventHandlerDict : TypeAlias = dict [str , EventHandlerType ]
434+ """A dict mapping between event names to their handlers"""
435+
436+
440437class VdomDictConstructor (Protocol ):
441438 """Standard function for constructing a :class:`VdomDict`"""
442439
0 commit comments