glyph/automat ? reverse-engineered prompt

Reverse engineered prompt

Build me a small Python library for defining finite state machines in a really clean, Pythonic way.

I want the public API to let me describe states, connect transitions, and then build a callable object that behaves like a normal class with methods for each input. The goal is that someone using it does not have to think about generic event objects, they should just call methods and the right state changes and side effects happen automatically.

Please include a simple example like a coffee machine so it is easy to understand how to use it. I also want clear type hints, good docs, and tests that show the main behavior. Make sure it supports the idea of a shared core object plus state specific transitions, and that outputs can either return a value or run some action.

If you need to check current Python docs or typing details, go ahead and look them up online.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab