v.2.1.0
StateMachine 2.1.0
June 11, 2023
What's new in 2.1.0
Added support for declaring states using Enum
Given an Enum
type that declares our expected states:
>>> from enum import Enum
>>> class Status(Enum):
... pending = 1
... completed = 2
A StateMachine can be declared as follows:
>>> from statemachine import StateMachine
>>> from statemachine.states import States
>>> class ApprovalMachine(StateMachine):
...
... _ = States.from_enum(Status, initial=Status.pending, final=Status.completed)
...
... finish = _.pending.to(_.completed)
...
... def on_enter_completed(self):
... print("Completed!")