yera.typing.validate

Validation: checking that an app's annotations are drawn from the supported set.

Symbols

def is_allowed_type — Check whether a type hint is supported for validation and serialization.
def validate_signature — Validate a function's parameters and return type against supported types.

is_allowed_type

is_allowed_type(
    type_hint: type | None,
) → bool

Check whether a type hint is supported for validation and serialization.

Parameters

type_hint
type: type | None

A Python type (e.g., int, list[str], MyEnum, pd.DataFrame).

Returns

type: bool

True if the type is in the allowed set; False otherwise.

validate_signature

validate_signature(
    fn: Callable,
    type_hints: dict[str, type],
    identifier: str | None = None,
) → None

Validate a function's parameters and return type against supported types.

Parameters

fn
type: Callable

The function to inspect.

type_hints
type: dict[str, type]

The resolved type hints (as from typing.get_type_hints()).

identifier
type: str | None = None

Optional human-readable name for error messages.

Raises

TypeError

If unsupported parameter kinds are found, or if required parameters lack type hints, or if any type hint is not supported.