You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to take a short-cut in my state machine, validator returned a list (empty list would mean False) and the error message was not related to the actual problem.
I wonder if it would make sense to emphasize (in example, maybe) that validators need to return bool value.
Or make it checked somehow? if a guard gets something else than a bool, it would log a warning?
Or then, it's also possible to coerce to bool... not sure which is best here.
Hi @jpoikela , how are you? Thanks, glad you liked it!
There's a mismatch here, Validators are expected to raise exceptions:
Are like Guards, but instead of evaluating to boolean, they are expected to raise an exception to stop the flow.
If you meant Guards, then you're correct as at 1.0.3 they only work with bool returns, and not with falsy or truthy values like evaluating an empty list as a false value. However, this is already implemented and will be released in the 2.0 version.
#342: Guards now supports the evaluation of truthy** and falsy values.
I planned to release 2.0 after #329, but I may consider releasing it before as I'm still trying to work on it.
Activity
fgmacedo commentedon Feb 22, 2023
Hi @jpoikela , how are you? Thanks, glad you liked it!
There's a mismatch here, Validators are expected to raise exceptions:
If you meant Guards, then you're correct as at
1.0.3they only work withboolreturns, and not withfalsyortruthyvalues like evaluating an empty list as a false value. However, this is already implemented and will be released in the 2.0 version.I planned to release 2.0 after #329, but I may consider releasing it before as I'm still trying to work on it.
fgmacedo commentedon Feb 22, 2023
Closing as fixed in #342. Feel free to reopen if something else is missing.
jpoikela commentedon Feb 24, 2023
ah, sorry. I was using wrong words and had not read carefully enough, it reads there clearly.
and truthy values already on your list, cool!
thanks!
fgmacedo commentedon Mar 6, 2023
@jpoikela the new version was released: https://python-statemachine.readthedocs.io/en/2.0.0/releases/2.0.0.html