Skip to content

Diagnostics⚓︎

diagnostics ⚓︎

Immutable diagnostics and non-raising validation results.

Diagnostic Model v1 is shared by runtime parsing, static checking, the CLI, and integrations. Exception classes in :mod:talika.errors are compatibility adapters around these values rather than a second diagnostic representation.

DiagnosticSeverity ⚓︎

Bases: str, Enum

Severity values supported by Diagnostic Model v1.

TalikaWarning ⚓︎

TalikaWarning(diagnostic: Diagnostic)

Bases: UserWarning

Expose one structured Talika diagnostic through Python warnings.

Raising parse APIs return their normal records or output models when validation reports warning-severity diagnostics. Each diagnostic is also emitted as TalikaWarning so callers may display, filter, or assert it with the standard :mod:warnings tools.

Attributes:

  • diagnostic

    Immutable warning-severity diagnostic produced by Talika.

Parameters:

  • diagnostic (Diagnostic) –

    Structured diagnostic to expose as a Python warning.

Raises:

  • ValueError

    If the diagnostic does not have warning severity.

Example

with pytest.warns(TalikaWarning) as captured:
    records = UserTable.parse(datatable)

assert captured[0].message.diagnostic.code == "legacy_value"

Diagnostic dataclass ⚓︎

Diagnostic(
    *,
    code: str,
    message: str,
    severity: DiagnosticSeverity | str = ERROR,
    hint: str | None = None,
    schema_name: str | None = None,
    field_name: str | None = None,
    field_label: str | None = None,
    source_uri: str | None = None,
    row: int | None = None,
    column: int | None = None,
    item_id: Any = _UNSET,
    source_value: Any = _UNSET,
    logical_value: Any = _UNSET,
    cause: BaseException | None = None,
)

One immutable, source-aware Diagnostic Model v1 value.

item_id property ⚓︎

item_id: Any | None

Return the item ID, or None when it was omitted.

has_item_id property ⚓︎

has_item_id: bool

Return whether the diagnostic explicitly carries an item ID.

source_value property ⚓︎

source_value: Any | None

Return the original source value, or None when omitted.

has_source_value property ⚓︎

has_source_value: bool

Return whether an original source value is present.

logical_value property ⚓︎

logical_value: Any | None

Return the logical/transformed value, or None when omitted.

has_logical_value property ⚓︎

has_logical_value: bool

Return whether a logical/transformed value is present.

as_dict ⚓︎

as_dict() -> dict[str, Any]

Return a deterministic JSON-compatible Diagnostic Model v1 mapping.

ValidationResult dataclass ⚓︎

ValidationResult(
    records: tuple[T, ...] = (), diagnostics: tuple[Diagnostic, ...] = ()
)

Bases: Generic[T]

Non-raising result returned by Schema.validate().

errors property ⚓︎

errors: tuple[Diagnostic, ...]

Return error-severity diagnostics in discovery order.

warnings property ⚓︎

warnings: tuple[Diagnostic, ...]

Return warning-severity diagnostics in discovery order.

valid property ⚓︎

valid: bool

Return whether validation found no error-severity diagnostics.

stable_json_value ⚓︎

stable_json_value(value: Any) -> Any

Convert an arbitrary project value into deterministic JSON data.

The conversion intentionally never falls back to an object's repr or str implementation. Those methods may include memory addresses or other process-specific data that would make checker output unstable.

stable_text_value ⚓︎

stable_text_value(value: Any) -> str

Return a compact deterministic value representation for text errors.

stable_callable_name ⚓︎

stable_callable_name(value: object) -> str

Return a callable identity without invoking project formatting hooks.