ValueHashedFields.require_parameters_are_fields#

t3toolbox.backend.common.ValueHashedFields.require_parameters_are_fields()#
def require_parameters_are_fields(self) -> None:

Reject a parameter that was stashed on the instance instead of declared as a field.

The value identity is built from dc.fields(self), so anything else an instance carries is invisible to it – two objects that differ only in such a value compare EQUAL, and since these objects are jax aux_data one of them silently receives the other’s compiled program. That makes “parameters are fields” a correctness rule, not a style preference, and this turns the three ways of breaking it (a hand-written __init__, a bare class attribute assigned per instance, a class that forgot its @dataclass decorator) into a construction-time error.

Call it from __post_init__. Values cached by functools.cached_property also live in __dict__ by design and are skipped – they are derived, never parameters.

Return type:

None