# fgmacedo/python-statemachine

Expressive statecharts and FSMs for modern Python.

Repository: https://github.com/fgmacedo/python-statemachine
Canonical: https://ross.abutalabs.com/products/python-statemachine
Homepage: https://python-statemachine.readthedocs.io
Language: Python
License: MIT
License Family: permissive
Topics: state-machine, statemachine, automata, finite-state-machine, python, fsm, fsm-library, state, state-machine-diagram, state-machine-dsl, state-management, scxml, statechart, statecharts, hierarchical-state-machine, hsm, harel-statechart
Last push: 2026-08-17T21:38:31+00:00

## Health v2 (maintenance only)
Score: 93/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 98, release rhythm 83, longevity 100
- inputs: {"age_days": 3451, "days_push": 16, "days_rel": 32, "gap_med": 37.0, "n_releases_24m": 9}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1298, forks 109 (observed 2026-08-28T04:04:17.267183+00:00)

## What it is
A Python library for defining finite state machines and full Harel statecharts with a declarative, pythonic API. It supports compound states, parallel regions, history, sync/async code, and diagram generation.

## Use cases
- model business logic as a state machine in Python
- implement statecharts with hierarchical and parallel states
- add finite state machine behavior to a Python class
- generate state machine diagrams from code
- manage async state transitions in Python applications

## When to choose
- you need expressive statecharts (compound, parallel, history states) in Python
- you want a clean declarative DSL with hooks like on_enter/on_exit and guards
- you need both sync and async support
- you want automatic diagram or markdown documentation of transitions

## When to avoid
- you need a distributed or persistent workflow engine rather than in-process state logic
- your project is not Python
- you only need simple boolean flags instead of formal state modeling

## Facets
- artifact type: library
- maturity: active
- function: state-management, developer-tools
- domain: developer-tools
- platform: python, cross-platform
- tags: state-machine, statechart, fsm, harel-statechart, scxml, hierarchical-state-machine, async-support, diagram-generation, automation, algorithms

## Member repositories
- fgmacedo/python-statemachine (main) score 93

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:17.267183+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T04:53:49.972435+00:00, confidence not recorded.
  - readme: https://github.com/fgmacedo/python-statemachine (fetched 2026-08-28T04:04:17.267183+00:00, sha 69823f506a7a)
  - registry_pypi: https://pypi.org/pypi/python-statemachine/json (fetched 2026-08-29T12:10:40.942274+00:00, sha 3a82f563005d)
- Data as of 2026-08-30T08:39:29.467469+00:00.
