Skip to content

Commit

Permalink
Merge branch 'master' into rq-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
selwin committed Oct 19, 2024
2 parents 9722a96 + a953e6a commit aa55e5a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
31 changes: 29 additions & 2 deletions django_rq/decorators.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
from rq.decorators import job as _rq_job
from typing import TYPE_CHECKING, Union
from typing import Any, Callable, Optional, overload, Protocol, TYPE_CHECKING, TypeVar, Union

from django.conf import settings

from .queues import get_queue

if TYPE_CHECKING:
from redis import Redis
from rq import Queue
from typing_extensions import ParamSpec

P = ParamSpec('P')
R = TypeVar('R', covariant=True)

def job(func_or_queue, connection=None, *args, **kwargs):
class _JobFn(Protocol[P, R]):
def delay(self, *args: P.args, **kwargs: P.kwargs) -> R: ...
def enqueue(self, *args: P.args, **kwargs: P.kwargs) -> R: ...
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R: ...


@overload
def job(func_or_queue: 'Callable[P, R]') -> '_JobFn[P, R]': ...

@overload
def job(
func_or_queue: Union['Queue', str],
connection: Optional['Redis'] = None,
*args: Any,
**kwargs: Any,
) -> Callable[['Callable[P, R]'], '_JobFn[P, R]']: ...


def job(
func_or_queue: Union['Callable[P, R]', 'Queue', str],
connection: Optional['Redis'] = None,
*args: Any,
**kwargs: Any,
) -> Union['_JobFn[P, R]', Callable[['Callable[P, R]'], '_JobFn[P, R]']]:
"""
The same as RQ's job decorator, but it automatically works out
the ``connection`` argument from RQ_QUEUES.
Expand Down
2 changes: 1 addition & 1 deletion integration_test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-e ..
Django==3.2.25
Django==4.2.16
gunicorn==22.0.0
psycopg2==2.9.7
requests==2.32.0

0 comments on commit aa55e5a

Please sign in to comment.