Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion celery-stubs/app/task.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ from celery.worker.request import _DeliveryInfo
from typing_extensions import ParamSpec

_P = ParamSpec("_P")
_R = TypeVar("_R")
_R = TypeVar("_R", covariant=True)
_SigR = TypeVar("_SigR")

class Context:
Expand Down
2 changes: 1 addition & 1 deletion celery-stubs/canvas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from celery.result import EagerResult
from celery.utils import abstract

_F = TypeVar("_F", bound=Callable[..., Any])
_R = TypeVar("_R")
_R = TypeVar("_R", covariant=True)

class Signature(dict[str, Any], Generic[_R]):
@classmethod
Expand Down
2 changes: 1 addition & 1 deletion celery-stubs/result.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ResultBase:

_State = Literal["PENDING", "STARTED", "RETRY", "FAILURE", "SUCCESS"]

_R = TypeVar("_R")
_R = TypeVar("_R", covariant=True)

class AsyncResult(ResultBase, Generic[_R]):
app: Celery
Expand Down
16 changes: 16 additions & 0 deletions tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ def add(x: int, y: int) -> None:
add.delay(1, 2)


def test_covariant_assignment() -> None:
@app.task()
def foo() -> None:
pass

sig: Signature[None] = foo.s()
result: AsyncResult[None] = sig.apply_async()

def test_covariance(
t: Task[[], object], s: Signature[object], r: AsyncResult[object]
) -> None:
pass

test_covariance(foo, sig, result)


def test_link() -> None:
@app.task()
def foo() -> None:
Expand Down
Loading