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
Expand the return type for matches to be a tuple [bool, str | None] where the 2nd element contains an explaination of the failure when bool = False
It would also be nice to give the rule an optional name
e.g.
matched, reason = Rule("flux-capacitor", "foo < 3 and bar == 1" ).matches({"foo": 5, "bar": 1})
# matched: False
# reason: "The flux-capacitor failed because the value of 'foo' is 5, it must be less than 3"
I might be able to take a stab at it, if you think it's a useful feature. I'd want to hammer out how to format multiple failures in a single rule.
The text was updated successfully, but these errors were encountered:
It may be more flexible to forgo naming the rule and extend the return type to be (bool, list[str] | None), basically return a readable string for each failure,
matched, reasons = Rule("foo < 3 and bar == 2" ).matches({"foo": 5, "bar": 1})
# matched: False
# reasons: ["The value of 'foo' is 5, it must be less than 3", "The value of 'bar' is 1, it must be 2"]
Yeah that could be interesting. If you do implement it, please add a new function instead of changing the return type of matches to ensure it's backwards compatible. Maybe something like matches_with_reasons, IDK.
Expand the return type for matches to be a tuple
[bool, str | None]
where the 2nd element contains an explaination of the failure whenbool = False
It would also be nice to give the rule an optional name
e.g.
I might be able to take a stab at it, if you think it's a useful feature. I'd want to hammer out how to format multiple failures in a single rule.
The text was updated successfully, but these errors were encountered: