htmy.typing
AsyncFunctionComponent = Callable[[T, Context], Coroutine[Any, Any, Component]]
module-attribute
Protocol definition for async function components.
Component = ComponentType | ComponentSequence
module-attribute
Component type: a single component or a sequence of components.
ComponentSequence = list[ComponentType] | tuple[ComponentType, ...]
module-attribute
Component sequence type.
ComponentType = HTMYComponentType | str
module-attribute
Type definition for a single component.
Context = Mapping[ContextKey, ContextValue]
module-attribute
Context mapping.
ContextKey = Any
module-attribute
Context key.
ContextProvider = SyncContextProvider | AsyncContextProvider
module-attribute
Context provider type.
ContextValue = Any
module-attribute
Context value.
FunctionComponent = SyncFunctionComponent[T] | AsyncFunctionComponent[T]
module-attribute
Function component type.
HTMYComponentType = SyncComponent | AsyncComponent
module-attribute
Sync or async htmy
component type.
MutableContext = MutableMapping[ContextKey, ContextValue]
module-attribute
Mutable context mapping.
It can be helpful when the created context should be marked as mutable for static type analysis
(usually the created context is a plain dict
).
Properties = Mapping[str, PropertyValue]
module-attribute
Component/XML tag property mapping.
PropertyValue = Any | None
module-attribute
Component/XML tag property value.
SyncFunctionComponent = Callable[[T, Context], Component]
module-attribute
Protocol definition for sync function components.
TextProcessor = Callable[[str, Context], str | Coroutine[Any, Any, str]]
module-attribute
Callable type that expects a string and a context, and returns a processed string.
AsyncComponent
Bases: Protocol
Protocol definition for async htmy
components.
Source code in htmy/typing.py
AsyncContextProvider
Bases: Protocol
Protocol definition for async context providers.
Source code in htmy/typing.py
SyncComponent
Bases: Protocol
Protocol definition for sync htmy
components.
Source code in htmy/typing.py
SyncContextProvider
Bases: Protocol
Protocol definition for sync context providers.
Source code in htmy/typing.py
TextResolver
Bases: Protocol
Protocol definition for resolvers that convert a string to a component.
Source code in htmy/typing.py
resolve_text(text)
Returns the resolved component for the given text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to resolve. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If the text cannot be resolved to a component. |