fix: support States.from_enum() inside compound and parallel states#607
Merged
fix: support States.from_enum() inside compound and parallel states#607
Conversation
…#606) `NestedStateFactory.__new__()` only checked for individual `State` instances when processing compound/parallel class bodies, silently ignoring `States` objects returned by `from_enum()`. Add a `States` isinstance check to unpack the collection into individual states, matching what `StateMachineMetaclass` already does at the top level. Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #607 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 42 42
Lines 5019 5024 +5
Branches 810 812 +2
=========================================
+ Hits 5019 5024 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fgmacedo
added a commit
that referenced
this pull request
Apr 3, 2026
Document missing StateChart members: **kwargs on __init__, model and
history_values instance attributes, events property. Fix typo in
listeners parameter ("provies" -> "provides").
Add missing bugfixes to 3.1.0 release notes: Configuration write-through
(#596) and States.from_enum() in compound/parallel states (#607).
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.



Closes #606
Summary
NestedStateFactory.__new__()now handlesStatesobjects (returned byStates.from_enum()) insideState.CompoundandState.Parallelclass bodies, unpacking them into individual statesfrom_enum()The root cause was that
NestedStateFactoryonly checked for individualStateinstances when iterating over class attributes, silently ignoringStatescontainers. The fix adds anisinstance(value, States)check that mirrors whatStateMachineMetaclass.add_from_attributes()already does at the top level.