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
5 changes: 4 additions & 1 deletion celery-stubs/contrib/abortable.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Generic, ParamSpec, TypeVar
from typing import Any, Generic, ParamSpec, TypeVar, overload

from celery import Task
from celery.result import AsyncResult
Expand All @@ -20,4 +20,7 @@ class AbortableTask(Task[_P, _R_co], Generic[_P, _R_co]):

@override
def AsyncResult(self, task_id: str) -> AbortableAsyncResult[_R_co]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
@overload
def is_aborted(self, *, task_id: str, **kwargs: Any) -> bool: ...
@overload
def is_aborted(self, **kwargs: Any) -> bool: ...
5 changes: 5 additions & 0 deletions tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
if TYPE_CHECKING:
from collections.abc import Iterator

from celery.contrib.abortable import AbortableTask
from celery.contrib.django.task import DjangoTask

app = celery.Celery()
Expand Down Expand Up @@ -364,3 +365,7 @@ def test_celery_top_level_exports() -> None:
def test_djangotask(task: DjangoTask[[int, int], Any]) -> None:
task.delay_on_commit(1, 2)
task.apply_async_on_commit((1, 2), countdown=10.0)


def test_abortabletask(task: AbortableTask[[], None]) -> None:
task.is_aborted()
Loading