Skip to content

fix: isolate transitions declared by statechart subclasses - #737

Open
cangxing314 wants to merge 1 commit into
fgmacedo:mainfrom
cangxing314:fix/inherited-statechart-transitions
Open

cangxing314 wants to merge 1 commit into
fgmacedo:mainfrom
cangxing314:fix/inherited-statechart-transitions

Conversation

@cangxing314

Copy link
Copy Markdown

Fixes #733.

Problem

Declaring a transition from an inherited state updates that state's transition list while Python is still evaluating the subclass body. The base class and earlier sibling classes then see a transition that is absent from their event registries. Siblings defined afterward can also inherit the subclass-only event.

Change

  • Defer attachment when a transition builder uses a state that already belongs to a chart.
  • Give classes that extend an inherited graph their own state and transition definitions. Preserve the hierarchy, transition targets, and callback references when rebinding the graph.
  • Add regression coverage for siblings declared before and after the extension, nested states, inherited callbacks, and wildcard transitions.

Validation

  • Ran the complete pytest suite with branch coverage in Linux on Python 3.13.
  • Ran the repository's pre-commit hooks.

This contribution was prepared with Codex assistance.

Signed-off-by: cangxing314 <2625399797@qq.com>
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

bug: subclass transitions mutate shared inherited state

1 participant