Statomata
Statomata is a strictly typed, flexible library for building and running finite state machines (FSMs) and automata in Python. It provides core automata implementations out of the box and lets you define custom states and state management logic.
Features
- 🧠 State Interface & Context: Follow the state machine OOP pattern with clear, isolated state definitions.
- ⏸️ Defer & Recall: States can defer incoming messages and recall them later, enabling complex multi-step workflows.
- ⚡ Built-in Automata: feel free to use one of the predefined automata classes from SDK (sync / async; unary / iterable)
- 🏗 Custom Automata Support: Build your own automata with custom state management logic. You can choose declarative style or built custom automata using provided interfaces.
- ✅ Strict Typing: Designed for type safety and clarity with full type hints.
Installation
pip install statomata
Quick Start
Use high-level declarative style:
from statomata.declarative import DeclarativeStateMachine, State
class OpenCloseExample(DeclarativeStateMachine):
closed = State(initial=True)
opened = State()
@closed.to(opened)
def open(self) -> str:
return "Opened"
@opened.to(closed)
def close(self) -> str:
return "Closed"
Run the state machine:
from contextlib import suppress
from statomata.exception import InvalidStateError
sm = OpenCloseExample()
print(sm.open()) # Output: Opened
print(sm.close()) # Output: Closed
with suppress(InvalidStateError):
sm.close()
Or you can use low-level style:
from statomata.abc import State, Context
from statomata.exception import InvalidStateError
class OpenState(State[str, str]):
def handle(self, income: str, context: Context[State[str, str]]) -> str:
if income != "close":
raise InvalidStateError(self, message="already opened")
context.set_state(ClosedState())
return "Closed"
class ClosedState(State[str, str]):
def handle(self, income: str, context: Context[State[str, str]]) -> str:
if income != "open":
raise InvalidStateError(self, message="already closed")
context.set_state(OpenState())
return "Opened"
Run the state machine:
from contextlib import suppress
from statomata.exception import InvalidStateError
from statomata.sdk import create_unary_sm
sm = create_unary_sm(ClosedState())
print(sm.run("open")) # Output: Opened
print(sm.run("close")) # Output: Closed
with suppress(InvalidStateError):
sm.run("close")
Examples
Metadata
Release files for statomata 0.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| statomata-0.4.3.tar.gz | 19.3 kB | With provenance | Details for statomata-0.4.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| statomata-0.4.3-py3-none-any.whl | Python 3 | none | any | Details for statomata-0.4.3-py3-none-any.whl |
Total release size: 43.2 kB
Release files / statomata-0.4.3.tar.gz
| Download URL | statomata-0.4.3.tar.gz |
|---|---|
| Size | 19.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2fd70d78a786809fdb91fb12d7393d57155f3aad251287d83eb2802c21802c4
|
|
BLAKE2b-256 checksum How to use checksums |
64fa187b185fcb8f2526f64c0066aa7803934111b7aeb915767eb219b4f88fe4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 7, 2025.
Transparency logRelease files / statomata-0.4.3-py3-none-any.whl
| Download URL | statomata-0.4.3-py3-none-any.whl |
|---|---|
| Size | 23.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef3cf2ded77cc739660fd971fadfc3ae696e89d388fad0b0c78e5e7de25ac28f
|
|
BLAKE2b-256 checksum How to use checksums |
a15d4907bdfd40fa40029d053ee9a94c00bd1b12661df78cf7b029426c1e85ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 7, 2025.
Transparency logSecurity for statomata 0.4.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for statomata-0.4.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 7, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.