a strictly typed, flexible library for building and running state machines in Python
Project description
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 pattern with clear, isolated state definitions.
- ⚡ Built-in Automata: Unary, async unary, unary iterable, and async iterable automata.
- 🏗 Custom Automata Support: Build your own automata with custom state management logic.
- ✅ Strict Typing: Designed for type safety and clarity with full type hints.
Installation
pip install statomata
Quick Start
Define your states:
from statomata.abc import State, Context
class OpenState(State[str, str]):
def handle(self, income: str, context: Context[State[str, str]]) -> str:
if income == "close":
context.set_state(ClosedState())
return "Closed"
return "Still open"
class ClosedState(State[str, str]):
def handle(self, income: str, context: Context[State[str, str]]) -> str:
if income == "open":
context.set_state(OpenState())
return "Opened"
return "Still closed"
Run the state machine with a built-in automaton:
from statomata.sdk import create_unary_sm
sm = create_unary_sm(OpenState())
print(sm.run("close")) # Output: Closed
print(sm.run("open")) # Output: Opened
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file statomata-0.1.0.tar.gz.
File metadata
- Download URL: statomata-0.1.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a66f614ea6e856123fa4e724ab247018eb177f8ee3985c8697788609f2aa17b
|
|
| MD5 |
06dcfb993c7b2cbaa7a6c3cd6e799584
|
|
| BLAKE2b-256 |
32714851930e3570ec22c74cc66a8d0225b6169351ae88056403e37b040a081b
|
Provenance
The following attestation bundles were made for statomata-0.1.0.tar.gz:
Publisher:
publish.yaml on zerlok/statomata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
statomata-0.1.0.tar.gz -
Subject digest:
7a66f614ea6e856123fa4e724ab247018eb177f8ee3985c8697788609f2aa17b - Sigstore transparency entry: 181223881
- Sigstore integration time:
-
Permalink:
zerlok/statomata@1d46c00569b9ee6deb3e8d759a4b3b7abdeb2844 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/zerlok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1d46c00569b9ee6deb3e8d759a4b3b7abdeb2844 -
Trigger Event:
release
-
Statement type:
File details
Details for the file statomata-0.1.0-py3-none-any.whl.
File metadata
- Download URL: statomata-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48bb460f21ada4e1ea7749195b13cf420d86ccd3b1c7d748deb326d331b7e2f7
|
|
| MD5 |
c4c44f41e28c72dfb174c1287073c0f5
|
|
| BLAKE2b-256 |
c2d53f8097518cfcce4f3b6c7c9a82aee0cad8306e65420f7f558f70a91cb96e
|
Provenance
The following attestation bundles were made for statomata-0.1.0-py3-none-any.whl:
Publisher:
publish.yaml on zerlok/statomata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
statomata-0.1.0-py3-none-any.whl -
Subject digest:
48bb460f21ada4e1ea7749195b13cf420d86ccd3b1c7d748deb326d331b7e2f7 - Sigstore transparency entry: 181223883
- Sigstore integration time:
-
Permalink:
zerlok/statomata@1d46c00569b9ee6deb3e8d759a4b3b7abdeb2844 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/zerlok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1d46c00569b9ee6deb3e8d759a4b3b7abdeb2844 -
Trigger Event:
release
-
Statement type: