Dependency injection using `Annotated` fails with `from __future__ import annotations`
itssimon opened this issue · 3 comments
When using the Annotated
syntax for Taskiq dependencies and having the from __future__ import annotations
import at the top of the file, dependency injection doesn't work. An error like below will be thrown:
TypeError: my_task() missing 1 required positional argument: 'my_dep'
I can imagine that this may be expected, so I'd suggest adding a note in the documentation so people don't waste as much time debugging this like I just did :)
Otherwise, maybe there is a clue in FastAPI on how to make it work even with the import from __future__
?
Since the algorithm we implemented in the taskiq-dependencies is completely different to fastapi's DI, there would be no hints for fixing it. But I will debug this issue.
Now everything should work fine with from __future__ import annotations
for python versions >= 3.10. Please update the taskiq-dependencies package to version 1.5.0 and verify.
If that works for you, consider closing the issue.
That works. Thank you!