Repository navigation
Conversation
The reachability walk followed only the first target of a transition, so a UML fork written as a.to([x, y]) reported the second target as unreachable when it had no other incoming transition. Walk every target instead, which also fixes the path-to-final-state check that shares the same walk. Document multi-target transitions as the UML fork in docs/transitions.md, and widen the to() type hint so the documented spelling type-checks. Signed-off-by: Tung Lam <53996158+tunglambk@users.noreply.github.com>
|
This branch has not been deployed
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.



Fixes #705
Why
The reachability walk in
statemachine/graph.pyfollowed onlytransition.target, so a UML fork written asa.to([x, y])reported the second target as unreachable when nothing else pointed at it:Loaded documents turn the structural checks off (
statemachine/io/interpreter.py), which is why the PSSM and SCXML cases never hit this.What changes
visit_connected_statesnow queues everytransition.targets. Both callers share that walk — the disconnected-state check and the path-to-final-state check — so a fork now counts in full for reachability. Single-target and target-less transitions are unchanged.docs/transitions.mddocuments multi-target transitions as the UML fork, next to the other transition-declaration behaviour, with a doctest that enters two parallel regions in one step._ToState.__call__acceptslist[State]so the documented spelling type-checks.Evidence
tests/test_statemachine.py::test_fork_multi_target_transition_is_reachablefails onmainwithDisconnected states: ['y2']and passes after the change. It also checks the fork leaves the machine in{active, r1, r2, x2, y2}.Fork_001andFork_002still xfail exactly as before (they load through the IO path), and the rest of the PSSM and SCXML suites are unchanged.Serial
uv run pytest: 2810 passed, 189 skipped, 126 xfailed.ruff check,ruff format --check,mypy statemachine/ tests/andpyright statemachine/are clean, and all pre-commit hooks passed.graph.pyandstate.pystay at 100% branch coverage; the serial coverage total reports 96.31% only because graphviz'sdotbinary is missing here, so the diagram tests skip (the misses are all incontrib/diagram/*plus one diagram-docstring helper infactory.py, none of them touched).