fix(io): materialize transition validators from dict definitions#629
Open
csentis wants to merge 1 commit into
Open
fix(io): materialize transition validators from dict definitions#629csentis wants to merge 1 commit into
csentis 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>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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).