types

Shared laminar types.

Functions

hints

Get the type hints for a given function.

unwrap

Unwrap an optional value.

laminar.types.hints(execution: Execution, function: Callable[[...], Any]) tuple[Layer, ...]

Get the type hints for a given function.

Parameters
execution: Execution

Execution to get layers for.

function : Callable[..., Any]

Function to get type hints for.

Returns

Ordered type hints.

laminar.types.unwrap(option: T | None, default: T | None = None) T

Unwrap an optional value.

Usage:

unwrap("a")
>>> "a"
unwrap(None, "a")
>>> "a"
unwrap(None)
>>> ValueError
Parameters
option: T | None

Optional value to unwrap.

default: T | None = None

Default value if the optional value is None.

Raises

ValueError – If the option is None and no default is set.

Returns

Unwrapped optional value.