Skip to content

v.2.1.0

Compare
Choose a tag to compare
@fgmacedo fgmacedo released this 12 Jun 02:20
· 115 commits to develop since this release

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!")

See States from Enum types.

Bugfixes in 2.1.0

  • Fixes #369 adding support to wrap
    methods used as Actions decorated with functools.partial.
  • Fixes #384 so multiple observers can watch the same callback.