Skip to content

Incorrect typing for async actors #795

@janek-cosmose

Description

@janek-cosmose

Checklist

  • Does your title concisely summarize the problem?
  • Did you include a minimal, reproducible example?
  • What OS are you using?
  • What version of Python are you using?
  • What version of Dramatiq are you using?
  • What Broker are you using?
  • What did you do?
  • What did you expect would happen?
  • What happened?

What OS are you using?

Ubuntu 24.04

What version of Python are you using?

Python 3.12.7

What version of Dramatiq are you using?

2.0.0 (current master)

What Broker are you using?

Irrelevant for this issue

What did you do?

Tried do use mypy (version 1.18.2) with async actors. A minimal example:

import dramatiq

@dramatiq.actor
async def foo() -> None:
    pass


@dramatiq.actor()
async def bar() -> None:
    pass

What did you expect would happen?

I expected no errors from mypy.

What happened?

dramatiq/test.py:3:2: error: Argument 1 to "actor" has incompatible type
"Callable[[], Coroutine[Any, Any, None]]"; expected
"Callable[[], Awaitable[Never]]"  [arg-type]
    @dramatiq.actor
     ^
dramatiq/test.py:8:2: error: Argument 1 has incompatible type
"Callable[[], Coroutine[Any, Any, None]]"; expected
"Callable[[], Awaitable[Never]]"  [arg-type]
    @dramatiq.actor()
     ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions