-
Notifications
You must be signed in to change notification settings - Fork 56
Task.Request should accept type[Request], not just str #221
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
Task.Request is currently typed as str:
# celery-stubs/app/task.pyi
Request: strHowever, celery's own source code and documentation indicate it accepts either a string (dotted path) or a class:
# celery/app/task.py
#: Request class used, or the qualified name of one.
Request = 'celery.worker.request:Request'Assigning a Request subclass directly is a common and documented pattern:
from celery import Task
from celery.worker.request import Request
class MyRequest(Request):
...
class MyTask(Task):
Request = MyRequest # type error: Incompatible types in assignmentExpected type
Request: str | type[Request]Versions
- celery-types: 0.26.0
- celery: 5.6.x
- mypy: 1.15.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working