summaryrefslogtreecommitdiffstats
path: root/stator/graph.py
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-15 18:30:30 -0700
committerAndrew Godwin2022-11-15 15:30:32 -0700
commit20e63023bb0d3c7e4cb36b91b73e79f51889cc90 (patch)
tree96c99139f03550e35902440cd321290bc47f8f0f /stator/graph.py
parent4aa92744aea6097ffb784ca7de6bd95cc599988d (diff)
downloadtakahe-20e63023bb0d3c7e4cb36b91b73e79f51889cc90.tar.gz
takahe-20e63023bb0d3c7e4cb36b91b73e79f51889cc90.tar.bz2
takahe-20e63023bb0d3c7e4cb36b91b73e79f51889cc90.zip
Get outbound likes/boosts and their undos working
Diffstat (limited to 'stator/graph.py')
-rw-r--r--stator/graph.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/stator/graph.py b/stator/graph.py
index 00ef1c4..ef81d75 100644
--- a/stator/graph.py
+++ b/stator/graph.py
@@ -11,6 +11,7 @@ class StateGraph:
choices: ClassVar[List[Tuple[object, str]]]
initial_state: ClassVar["State"]
terminal_states: ClassVar[Set["State"]]
+ automatic_states: ClassVar[Set["State"]]
def __init_subclass__(cls) -> None:
# Collect state memebers
@@ -30,6 +31,7 @@ class StateGraph:
)
# Check the graph layout
terminal_states = set()
+ automatic_states = set()
initial_state = None
for state in cls.states.values():
# Check for multiple initial states
@@ -65,10 +67,12 @@ class StateGraph:
raise ValueError(
f"State '{state}' does not have a handler method ({state.handler_name})"
)
+ automatic_states.add(state)
if initial_state is None:
raise ValueError("The graph has no initial state")
cls.initial_state = initial_state
cls.terminal_states = terminal_states
+ cls.automatic_states = automatic_states
# Generate choices
cls.choices = [(name, name) for name in cls.states.keys()]