Automat
Self-service finite-state machines for the programmer on the go.
What it is and what it does
Automat is a finite-state machine library that lets you define stateful behavior using Python method calls and type protocols, rather than requiring you to pass generic input objects through a state engine. Instead of scattering conditional logic across methods to track state flags, you declare states and transitions upfront, and the library synthesizes a clean interface that enforces valid state sequences at runtime.
The library targets the common pattern where your code needs to behave differently depending on its state (like a coffee machine that should only brew when it has water, beans, and a closed lid), but your callers should not need to know or care that you've implemented it as a state machine. It depends only on typing_extensions and supports Python 3.9 through 3.13, with full type hints throughout.
Use it for:
- Implement protocol-based state machines for complex objects like network connections, protocol handlers, or device controllers that need strict state ordering.
- Build workflow engines or task schedulers where transitions between states must be explicit and validated at definition time.
- Create deterministic finite-state transducers that transform input sequences into output behaviors while maintaining clean, method-call-based APIs.
- Model state-dependent behavior in game logic, UI state management, or embedded systems where invalid state combinations must be impossible.
- Define type-safe state machines for async systems where each state transition can trigger side effects or return computed results.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automat provides a Python library for building finite-state machines using type-safe, method-based interfaces rather than generic input/output objects, letting you organize stateful behavior while keeping a clean API.
Yes, if you need to model stateful behavior with strict state ordering and want a clean, type-safe API. The permissive MIT license and low install friction make it low-risk. However, the 485-day gap since the last release suggests the project is aging; verify that it meets your Python version requirements (3.9+) and that its approach fits your use case before committing to it as a core dependency.
Install
automat on PyPI
pip
pip install automatuv
uv add automatpoetry
poetry add automatInstalling Automat
Before you install
Low install friction with a single lightweight runtime dependency (typing_extensions). Maintenance status is aging—last release was 485 days ago, though the repository remains active with a recent commit on 2026-01-13 and 647 stars.
License in practice
MIT license (permissive) allows free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
from automat import TypeMachineBuilder
from typing import Protocol
class MyStateMachine(Protocol):
def event(self) -> None: pass
builder = TypeMachineBuilder(MyStateMachine, CoreData)
state_a = builder.state("state_a")
state_b = builder.state("state_b")
state_a.upon(MyStateMachine.event).to(state_b).returns(None)
machine = builder.build()
Requires Python 3.9 or later; familiarity with typing.Protocol and state machine concepts recommended.
Verify before relying
- Whether the library is actively maintained or in maintenance-only mode given the 485-day gap since last release
- Performance characteristics and scalability limits for complex state machines with many states or transitions
- Real-world adoption patterns and whether it integrates well with async/await workflows
Package facts
| License | Copyright (c) 2014 Rackspace Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing_extensions |
| Maintenance | aging — 485 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 14,296,962/month — #1,239 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: automat-25.4.16-py3-none-any.whl
Keywords: fsm, state machine, automata
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
automatonAutomaton provides state machine classes and…
permissive · top 15,000 on PyPI
django-fsm-logAutomatically logs state transitions for Django…
permissive · top 15,000 on PyPI
transitionsTransitions is a lightweight state machine…
permissive · top 5,000 on PyPI
pyniniPynini compiles grammar rules into weighted…
permissive · top 15,000 on PyPI
outlines-coreOutlines-core provides structured text…
permissive · top 5,000 on PyPI
python-statemachineDefines finite state machines and statecharts…
permissive · top 5,000 on PyPI
django-fsm-2Adds declarative finite state machine support…
permissive · top 15,000 on PyPI
django-fsmProvides finite state machine support for…
permissive · top 15,000 on PyPI
cellpylibCellPyLib simulates 1- and 2-dimensional…
permissive · top 15,000 on PyPI
pydantic-graphA graph and finite state machine library that…
permissive · top 1,000 on PyPI