{"id":23774,"library":"fysom","title":"fysom","description":"A simple Python finite state machine (FSM) for state management in applications. Current version: 2.1.6. Release cadence is irregular, with maintenance updates as needed.","status":"active","version":"2.1.6","language":"python","source_language":"en","source_url":"https://github.com/mriehl/fysom","tags":["finite-state-machine","fsm","state-machine","python"],"install":[{"cmd":"pip install fysom","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"In previous versions, the import path included 'old' package. Use 'from fysom import Fysom' in 2.x.","wrong":"old.fysom.Fysom","symbol":"Fysom","correct":"from fysom import Fysom"}],"quickstart":{"code":"from fysom import Fysom\n\nfsm = Fysom({\n    'initial': 'asleep',\n    'events': [\n        {'name': 'wakeup', 'src': 'asleep', 'dst': 'awake'},\n        {'name': 'sleep', 'src': 'awake', 'dst': 'asleep'},\n    ]\n})\n\nprint(fsm.current)  # 'asleep'\nfsm.wakeup()\nprint(fsm.current)  # 'awake'\nfsm.sleep()\nprint(fsm.current)  # 'asleep'","lang":"python","description":"Create a simple state machine with two states and two events."},"warnings":[{"fix":"Use the new Fysom class with dictionary-based event definitions. Callbacks now receive the event object instead of state names as separate arguments.","message":"In version 2.0.0, the API changed significantly. The old 'FysomGlobal' and event callback signatures are deprecated. Upgrade scripts may break.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"In v2.x, set 'final' as a top-level key in the constructor dict: Fysom({'initial': 's1', 'final': 's5', 'events': [...]})","message":"The 'final' state support in event definitions (from v1.0.13) is deprecated; use the separate 'final' property in Fysom constructor instead.","severity":"deprecated","affected_versions":"<2.0.0"},{"fix":"Avoid naming events 'current', 'is_finished', or any reserved attribute.","message":"Event names must not conflict with method names on the Fysom object (e.g., 'current', 'is_finished'). Doing so will silently override or cause AttributeError.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade pip and setuptools: pip install --upgrade pip setuptools && pip install fysom","cause":"The package is not installed or pip install failed due to old setuptools.","error":"ImportError: No module named fysom"},{"fix":"In v2.x, events must be defined as a list of dictionaries, each with keys 'name', 'src', 'dst'. Example: events=[{'name': 'wake', 'src': 'asleep', 'dst': 'awake'}]","cause":"Using version 1.x style event definitions with separate arguments instead of a dictionary.","error":"TypeError: __init__() got an unexpected keyword argument 'src'"},{"fix":"Check the event definition; the method name is exactly the 'name' field of the event dictionary. Ensure it is lowercase and matches.","cause":"The event name is misspelled or the event was defined with a different name.","error":"AttributeError: 'Fysom' object has no attribute 'wakeup'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}