-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: 'type' object is not subscriptable #80
Comments
Oh at runtime, yeah I need to update the docs, you'll need to monkey patch Task to accept a generic argument: Task.__class_getitem__ = classmethod(lambda cls, *args, **kwargs: cls) # type: ignore [attr-defined] |
Another option is to do something like: from typing import TYPE_CHECKING
if TYPE_CHECKING:
class AnyTask[Any, Any]: ...
else:
AnyTask = Task
from celery.app.task import Task
from typing import Any
@app.task(bind=True)
def my_task(self: AnyTask): ... |
Would it be possible for this library to provide something like django_stubs_ext to do this for us? |
Yeah that’s possible but then we’d need to have a second package and it’s only a couple lines of code to copy |
In most cases you can get away with just sticking |
Ok, thank you for the clarification 👍 |
Is it the same if I want to use AsyncResult.__class_getitem__ = classmethod(lambda cls, *args, **kwargs: cls) # type: ignore [attr-defined] |
Yeah monkey patching |
Hello!
I have a problem with the new Task annotations.
I installed version 0.13.0 and started receiving typing errors on Task annotations (from #75)
So added the expected annotations, like:
But now celery (version 5.2.7) fails at runtime with:
What I'm missing? 😢
The text was updated successfully, but these errors were encountered: