Skip to content

Commit f552171

Browse files
committed
fix: Fix test533, ordering of entering states and exit/enter of parallel states
1 parent 60d547d commit f552171

6 files changed

Lines changed: 15 additions & 58 deletions

File tree

statemachine/engines/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def _enter_states( # noqa: C901
403403
)
404404

405405
ordered_states = sorted(
406-
states_to_enter, key=lambda x: x.source and x.source.document_order or 0
406+
states_to_enter, key=lambda x: x.target and x.target.document_order or 0
407407
)
408408

409409
# We update the configuration atomically

statemachine/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def __call__(self, *args, **kwargs):
157157
# an SM instance. Such SM instance is provided by `__get__` method when
158158
# used as a property descriptor.
159159
self.put(*args, **kwargs)
160-
return self._sm._processing_loop()
160+
return self._sm._processing_loop() # type: ignore
161161

162162
def split( # type: ignore[override]
163163
self, sep: "str | None" = None, maxsplit: int = -1

statemachine/io/scxml/actions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def __init__(self):
145145
def __call__(self, *args, **kwargs):
146146
raise NotImplementedError
147147

148+
def __str__(self):
149+
return f"{self.action}"
150+
148151
def __repr__(self):
149152
return f"{self.__class__.__name__}({self.action!r})"
150153

statemachine/io/scxml/schema.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@
99
class Action:
1010
pass
1111

12+
def __str__(self):
13+
return f"{self.__class__.__name__}"
14+
1215

1316
@dataclass
1417
class ExecutableContent:
1518
actions: List[Action] = field(default_factory=list)
1619

20+
def __str__(self):
21+
return ", ".join(str(action) for action in self.actions)
22+
1723
@property
1824
def is_empty(self):
1925
return not self.actions
@@ -41,6 +47,9 @@ class IfBranch(Action):
4147
cond: "str | None"
4248
actions: List[Action] = field(default_factory=list)
4349

50+
def __str__(self):
51+
return self.cond
52+
4453
def append(self, action: Action):
4554
self.actions.append(action)
4655

statemachine/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def parallel(self):
302302

303303
@property
304304
def is_compound(self):
305-
return bool(self.states)
305+
return bool(self.states) and not self.parallel
306306

307307
def ancestors(self, parent: "State | None" = None) -> Generator["State", None, None]: # noqa: UP043
308308
selected = self.parent

tests/scxml/w3c/mandatory/test533.fail.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)