fix(io): materialize transition validators from dict definitions#629
fix(io): materialize transition validators from dict definitions#629csentis wants to merge 1 commit into
Conversation
create_machine_class_from_definition threaded cond/unless/on/before/after into Transition(), but dropped validators — so a 'validators' entry in a dict/JSON definition was silently ignored and never ran at send(). The TransitionDict TypedDict also mistyped validators as bool. Pass validators through to Transition() and fix the type to the same callback-spec union as cond/unless. Adds a regression test proving a definition-supplied validator runs (and aborts) on send(). Closes #<issue>. Signed-off-by: Christian Sentis <christian.sentis@icloud.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #629 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 42 42
Lines 4976 4976
Branches 812 812
=========================================
Hits 4976 4976
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hi @csentis, thanks for the careful fix and the regression test. You spotted a real bug: a I've merged your change into One tiny follow-up on top (separate commit, not yours): the test asserted on Closing this PR since the commit is already on |



What
create_machine_class_from_definitionbuilds eachTransitionwithcond,unless,on,before, andafterfrom the definition — but droppedvalidators. So avalidatorsentry in a dict/JSON definition was silently ignored and never ran atsend(). TheTransitionDictTypedDict also mistypedvalidatorsasbool.This PR:
validatorsthrough toTransition(...)increate_machine_class_from_definition;TransitionDict.validatorsannotation to the same callback-spec union ascond/unless;tests/test_io.py::TestTransitionValidators) proving a definition-supplied validator runs and aborts onsend()(the test fails without the production change).Why
Transition.__init__already acceptsvalidators=; only the dict adapter wasn't passing it. Validators are the documented explicit-rejection channel (raise with a reason) — without this, dict/JSON-defined machines can't use it.Notes
validators.ruff checkclean;pytest tests/test_io.pygreen (4 passed).Closes #628