Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion statemachine/event.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from inspect import isawaitable
from typing import TYPE_CHECKING
from typing import Any
from typing import List
from uuid import uuid4

Expand Down Expand Up @@ -108,7 +109,7 @@ def __get__(self, instance, owner):
return self
return BoundEvent(id=self.id, name=self.name, _sm=instance)

def __call__(self, *args, **kwargs):
def __call__(self, *args, **kwargs) -> Any:
"""Send this event to the current state machine.

Triggering an event on a state machine means invoking or sending a signal, initiating the
Expand Down
6 changes: 3 additions & 3 deletions statemachine/statemachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ def _get_engine(self, rtc: bool):

return SyncEngine(self, rtc=rtc)

def activate_initial_state(self):
def activate_initial_state(self) -> Any:
result = self._engine.activate_initial_state()
if not isawaitable(result):
return result
return run_async_from_sync(result)

def _processing_loop(self):
def _processing_loop(self) -> Any:
return self._engine.processing_loop()

def __init_subclass__(cls, strict_states: bool = False):
Expand Down Expand Up @@ -298,7 +298,7 @@ def _put_nonblocking(self, trigger_data: TriggerData):
"""Put the trigger on the queue without blocking the caller."""
self._engine.put(trigger_data)

def send(self, event: str, *args, **kwargs):
def send(self, event: str, *args, **kwargs) -> Any:
"""Send an :ref:`Event` to the state machine.

.. seealso::
Expand Down
3 changes: 2 additions & 1 deletion statemachine/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import threading
from typing import Any

_cached_loop = threading.local()
"""Loop that will be used when the SM is running in a synchronous context. One loop per thread."""
Expand All @@ -25,7 +26,7 @@ def ensure_iterable(obj):
return [obj]


def run_async_from_sync(coroutine):
def run_async_from_sync(coroutine: Any) -> Any:
"""
Compatibility layer to run an async coroutine from a synchronous context.
"""
Expand Down
Loading