Skip to content

fix: support States.from_enum() inside compound and parallel states#607

Merged
fgmacedo merged 1 commit intodevelopfrom
fix/from-enum-in-compound-states
Apr 2, 2026
Merged

fix: support States.from_enum() inside compound and parallel states#607
fgmacedo merged 1 commit intodevelopfrom
fix/from-enum-in-compound-states

Conversation

@fgmacedo
Copy link
Copy Markdown
Owner

@fgmacedo fgmacedo commented Apr 2, 2026

Closes #606

Summary

  • NestedStateFactory.__new__() now handles States objects (returned by States.from_enum()) inside State.Compound and State.Parallel class bodies, unpacking them into individual states
  • Added tests for both compound and parallel states with from_enum()

The root cause was that NestedStateFactory only checked for individual State instances when iterating over class attributes, silently ignoring States containers. The fix adds an isinstance(value, States) check that mirrors what StateMachineMetaclass.add_from_attributes() already does at the top level.

…#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>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ec225e0) to head (802ad7d).
⚠️ Report is 1 commits behind head on develop.

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     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fgmacedo fgmacedo merged commit f76a160 into develop Apr 2, 2026
13 checks passed
@fgmacedo fgmacedo deleted the fix/from-enum-in-compound-states branch April 2, 2026 11:06
@fgmacedo fgmacedo added this to the 3.1.0 milestone Apr 3, 2026
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

from_enum in Compound States

1 participant