Automaton is a Python library for creating friendly and declarative state machines. It simplifies the definition and management of states, events, and transitions, making it easy to model complex system behaviors. The current version is 3.4.0, and the project is under active development with periodic releases.
pip install automatonVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to define a simple `LightSwitch` state machine with `off` and `on` states and `turn_on`/`turn_off` events. It shows state initialization, event triggering, and how `automaton` handles invalid transitions by raising an `InvalidTransition` exception.
Always explicitly define the `source` state for events (e.g., `Event(source=my_state, ...)`) to enforce strict state transitions, unless a 'global' transition from any state is genuinely desired.
Ensure all state transitions are performed by triggering `Event` objects (e.g., `my_machine.my_event()`) rather than reassigning `my_machine._current_state`.
Ensure your Python environment is 3.10 or newer. Upgrade your Python installation or use a virtual environment configured with a compatible Python version.
No dependency data recorded yet.