yera.apps.typing.coerce
Type coercion: converting values to declared types at app call time.
Symbols
coerce_bool
coerce_bool(
value: Any,
) → boolCoerce to bool with proper string handling.
coerce_dataframe
coerce_dataframe(
value: Any,
) → pd.DataFrameCoerce to pandas DataFrame.
coerce_date
coerce_date(
value: Any,
) → dateCoerce to date.
coerce_datetime
coerce_datetime(
value: Any,
) → datetimeCoerce to datetime.
coerce_decimal
coerce_decimal(
value: Any,
) → DecimalCoerce to Decimal.
coerce_dict
coerce_dict(
value: Any,
expected_type: Any,
) → dictCoerce to dict[K, V] type.
coerce_enum
coerce_enum(
value: Any,
expected_type: type[Enum],
) → EnumCoerce to Enum type.
coerce_fallback
coerce_fallback(
value: Any,
expected_type: Any,
) → AnyFallback coercion - just check isinstance.
coerce_float
coerce_float(
value: Any,
) → floatCoerce to float with proper string handling.
coerce_int
coerce_int(
value: Any,
) → intCoerce to int with proper string handling.
coerce_list
coerce_list(
value: Any,
expected_type: Any,
) → listCoerce to list[T] type.
coerce_literal
coerce_literal(
value: Any,
expected_type: Any,
) → AnyCoerce to Literal type.
coerce_none
coerce_none(
value: Any,
) → NoneCoerce to None type.
coerce_set
coerce_set(
value: Any,
expected_type: Any,
) → setCoerce a value to a set[T].
Accepts a set, list, or JSON-encoded string.
coerce_str
coerce_str(
value: Any,
) → strCoerce to str with proper string handling.
coerce_struct
coerce_struct(
value: Any,
expected_type: type[Struct],
) → AnyCoerce to Struct (Pydantic model) type.
coerce_time
coerce_time(
value: Any,
) → timeCoerce to time.
coerce_timedelta
coerce_timedelta(
value: Any,
) → timedeltaCoerce to timedelta.
coerce_union
coerce_union(
value: Any,
expected_type: Any,
) → AnyCoerce to Union type by trying each type in order.
coerce_value
coerce_value(
value: Any,
expected_type: Any,
) → AnyCoerce a value to the expected type.
Delegates to specialized handlers based on type structure.
is_generic
is_generic(
t: type,
) → boolReturn whether t is a parameterised generic origin (list, dict, set, Literal, Union).
serialise_dataframe
serialise_dataframe(
df: pd.DataFrame,
) → bytesSerialize DataFrame to Parquet bytes.