Axioms

didactic.api.axiom

axiom(
    expr: str,
    *,
    message: str | None = None,
    name: str | None = None,
) -> Axiom

Construct an Axiom for a class's __axioms__.

PARAMETER DESCRIPTION
expr

The axiom expression. Free variables are field names of the enclosing Model.

TYPE: str

message

Optional human-readable explanation surfaced when the axiom fails validation.

TYPE: str | None DEFAULT: None

name

Optional identifier. Defaults to the metaclass synthesising one from the expression text.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
Axiom

A frozen Axiom record. Place it in the class's __axioms__ list.

Examples:

>>> import didactic.api as dx
>>> class Pitched(dx.Model):
...     pitches: tuple[int, ...]
...     __axioms__ = [
...         dx.axiom("len(pitches) > 0", message="must be non-empty"),
...     ]

didactic.api.Axiom dataclass

Axiom(
    expr: str,
    message: str | None = None,
    name: str | None = None,
)

A class-level axiom expressed as a string.

PARAMETER DESCRIPTION
expr

The axiom expression in panproto-Expr-shaped surface syntax.

TYPE: str

message

Optional human-readable message surfaced in didactic.api.ValidationError when the axiom fails.

TYPE: str | None DEFAULT: None

name

Optional identifier; defaults to a generated label.

TYPE: str | None DEFAULT: None

See Also

axiom : the convenience constructor.