feat: add enabled_events() method (#520)#559
Merged
Conversation
The boolean expression combinators (custom_not, custom_and, custom_or, build_custom_operator) called predicates synchronously. When predicates were async, they returned unawaited coroutine objects which are always truthy, causing `not` to always return False, `and` to skip evaluation, and `or` to short-circuit incorrectly. Each combinator now checks `isawaitable()` on predicate results and returns a coroutine when needed, which CallbackWrapper.__call__ already knows how to await. Closes #535
The pre-commit hook was using ruff v0.8.1 while the lockfile had v0.15.0, causing import sorting differences between local and CI.
- Add docstrings to empty async on_enter_state methods (S1186) - Use await asyncio.sleep(0) in async test hooks to satisfy S7503
`allowed_events` returns events reachable from the current state but does not evaluate `cond`/`unless` guards. The new `enabled_events()` method evaluates conditions and returns only events that can actually fire. It accepts `*args`/`**kwargs` forwarded to condition callbacks, works with both sync and async engines, and treats condition exceptions as enabled (permissive behavior). Closes #520
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #559 +/- ##
===========================================
- Coverage 100.00% 99.77% -0.23%
===========================================
Files 25 25
Lines 1656 1748 +92
Branches 204 228 +24
===========================================
+ Hits 1656 1744 +88
- Misses 0 2 +2
- Partials 0 2 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
enabled_events(*args, **kwargs)method that evaluatescond/unlessguards and returns only events whose conditions are satisfied*args/**kwargsto condition callbacksdocs/guards.mdCloses #520