You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A root-level field accepts a value its declaration refuses; a nested field raises #47
What happens at 1fcdf12: update_parameter("ui.column_width", 4) on a nested field rebuilds the owning dataclass (_dataclass_ancestor_parameter_updates, src/objectstate/object_state.py:844), so a dataclass whose __post_init__ refuses the value raises and the state is left unchanged. For a field of the root object the function returns {} at its first line ("." not in param_name), nothing is constructed, the value is stored, subscribers are told it changed, and the refusal only appears later, at to_object() (:2607), far from the edit and after dirty_fields and every subscriber have already taken the bad value.
So whether an invalid edit is refused depends on how deep the field is.
Wanted: one rule for every depth: update_parameter constructs the object the new parameters describe before storing them, and raises without mutating when the declaration refuses it.
Workaround in Toad now:toad.forms.declared_views.DeclaredField.edit calls python_introspect.validation.validate_annotation_value on the field's annotation before update_parameter.
Acceptance: for @dataclass class Root(AnnotatedDataclassValidationMixin): count: Annotated[int, Ge(1)] = 3, ObjectState(Root()).update_parameter("count", 0) raises ValueError, parameters["count"] is still 3, no change callback fires and dirty_fields is empty.
Activity