pre and post hooks when state includes invalid function name characters
I'm unable to create pre_<state_name> and post_<state_name> call-backs for states that have characters not allowed in function names.
For example, a state named "in-progress" would look for a call-back pre_in-progress which is not allowed.
You are right, I wonder what can we do to prevent this issue, restrict the allowed values or convert to from - to _?
Converting invalid characters to _ would be the more flexible approach. There are a lot of use cases for having hyphens (or even spaces) in state values.
One possible implementation would be to add a method to BaseFiniteStateMachineMixin with a default implementation that converts invalid identifier characters to _ (i.e. anything that's not small case (a-z), upper case (A-Z), digit (0-9), or an underscore). Your change_state method could then call this method when determining the name of the call-back.
This lets someone who doesn't like the package's opinionated default override the method that converts the state value to one that can be used in a Python identifier.
Sounds good to me, would you mind submitting a PR?