pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.5k stars 525 forks source link

Type-safe Usage? #431

Closed GavanWilhite closed 4 years ago

GavanWilhite commented 4 years ago

Are there any ways to do type-safe transitions?

Enums or statically defined transition collections / function definitions?

I'm coming from TypeScript land, so perhaps this is swimming upstream.

aleneum commented 4 years ago

Hello @GavanWilhite,

many transitions features rely on Python's dynamic decoration and weak typing. Especially model convenience functions are decorated during runtime. This makes code completion and typing difficult (this issue has been discussed in #383 and #426). For Machine methods type hints are already included via docstrings but this wont change that we don't know much about models before they are decorated. If you have some suggestions about how to make transitions more type-safe, I'd be happy to give it a try.

aleneum commented 4 years ago

Due to the lack of feedback I will close this for now. I am more than willing to improve the type-save usage of transitions but don't know how that could be achieved right now. Feel free to comment in case you gathered new insights. I will reopen the issue if necessary.