YIDL Dataclass¶
Build Python data models with explicit rules for individual fields. Ordinary fields are writable slots. Add a converter for incoming text, a validator for accepted values, a factory for a dependent value, or a lazy field for work that should wait until first access.
When a model is assembled in stages, freezable=True adds a permanent freeze()
operation. You choose which fields cascade to child models or transform mutable
containers. When a model should be read-only from construction, use frozen=True.
Learn in order¶
- Your first model: install, declare fields, construct and inspect.
- Fields and generated behavior: defaults, field families, equality and slots.
- Initialize dependent values: factory arguments, hidden inputs and pipelines.
- Delay expensive values: first access, cached results and reset.
- Freeze a finished model: field policies, shallow freezing and partial failure.
- Copy and extend models: replacement, copying and inheritance.
Use the API reference for signatures, option constraints and callback contracts, and troubleshooting for common errors. The runnable examples are complete programs.
Requirements¶
The release tests CPython 3.12–3.15 subject to the
platform/backend boundary.
Install yidl-dataclass from PyPI; its declared runtime dependencies are
Astichi 1.1.5 and YIDL 0.1.4. The library generates Python
methods from YIDL templates when you decorate a class. Application code imports
yidl_dataclass; it does not need to author YIDL. See generation and source
inspection when you want to inspect those methods.
Annotations do not automatically check runtime types. Ordinary models accept
values as supplied; select conversion and validation to enforce field rules.
The supported behavior overlaps stdlib dataclasses, with deliberate extensions
and constraints documented throughout these guides.