Skip to content

Commit

Permalink
feat: Added typehints for awaitable actors. (#621)
Browse files Browse the repository at this point in the history
Co-authored-by: David Grigorenko <[email protected]>
  • Loading branch information
DABND19 and David Grigorenko authored Apr 23, 2024
1 parent 1fab55f commit a948bd1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dramatiq/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,17 @@ def __str__(self) -> str:


@overload
def actor(fn: Callable[P, R], **kwargs) -> Actor[P, R]:
def actor(fn: Callable[P, Union[Awaitable[R], R]], **kwargs) -> Actor[P, R]:
pass


@overload
def actor(fn: None = None, **kwargs) -> Callable[[Callable[P, R]], Actor[P, R]]:
def actor(fn: None = None, **kwargs) -> Callable[[Callable[P, Union[Awaitable[R], R]]], Actor[P, R]]:
pass


def actor(
fn: Optional[Callable[P, R]] = None,
fn: Optional[Callable[P, Union[Awaitable[R], R]]] = None,
*,
actor_class: Callable[..., Actor[P, R]] = Actor, # type: ignore[assignment]
actor_name: Optional[str] = None,
Expand Down Expand Up @@ -253,7 +253,7 @@ def actor(
Returns:
Actor: The decorated function.
"""
def decorator(fn: Callable[..., R]) -> Actor[P, R]:
def decorator(fn: Callable[..., Union[Awaitable[R], R]]) -> Actor[P, R]:
nonlocal actor_name, broker
actor_name = actor_name or fn.__name__
if not _queue_name_re.fullmatch(queue_name):
Expand Down

0 comments on commit a948bd1

Please sign in to comment.