|
6 | 6 | from functools import wraps |
7 | 7 | from typing import Any, Concatenate, Final, ParamSpec, TypeVar, overload |
8 | 8 |
|
9 | | -from celery import Celery, Task # type: ignore[import-untyped] |
| 9 | +from celery import Celery # type: ignore[import-untyped] |
10 | 10 | from celery.contrib.abortable import AbortableTask # type: ignore[import-untyped] |
11 | 11 | from pydantic import NonNegativeInt |
12 | 12 |
|
@@ -57,10 +57,15 @@ def _error_handling( |
57 | 57 | max_retries: NonNegativeInt, |
58 | 58 | delay_between_retries: timedelta, |
59 | 59 | dont_autoretry_for: tuple[type[Exception], ...], |
60 | | -): |
61 | | - def decorator(func: Callable[..., Any]) -> Callable[..., Any]: |
| 60 | +) -> Callable[ |
| 61 | + [Callable[Concatenate[AbortableTask, P], R]], |
| 62 | + Callable[Concatenate[AbortableTask, P], R], |
| 63 | +]: |
| 64 | + def decorator( |
| 65 | + func: Callable[Concatenate[AbortableTask, P], R], |
| 66 | + ) -> Callable[Concatenate[AbortableTask, P], R]: |
62 | 67 | @wraps(func) |
63 | | - def wrapper(task: Task, *args: Any, **kwargs: Any) -> Any: |
| 68 | + def wrapper(task: AbortableTask, *args: P.args, **kwargs: P.kwargs) -> R: |
64 | 69 | try: |
65 | 70 | return func(task, *args, **kwargs) |
66 | 71 | except Exception as exc: |
|
0 commit comments