Skip to content
Open
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
20 changes: 18 additions & 2 deletions dramatiq/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Generic,
Optional,
ParamSpec,
Protocol,
TypeVar,
Union,
overload,
Expand Down Expand Up @@ -202,13 +203,28 @@ def __str__(self) -> str:
return "Actor(%(actor_name)s)" % vars(self)


class ActorDecorator(Protocol):
@overload
def __call__(self, fn: Callable[P, Awaitable[R]]) -> Actor[P, R]: ...

@overload
def __call__(self, fn: Callable[P, R]) -> Actor[P, R]: ...

def __call__(self, fn: Callable[P, Union[Awaitable[R], R]]) -> Actor[P, R]: ...


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


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


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


Expand Down