summaryrefslogtreecommitdiff
path: root/rq/types.py
diff options
context:
space:
mode:
authorlowercase00 <21188280+lowercase00@users.noreply.github.com>2023-01-30 01:42:04 -0300
committerGitHub <noreply@github.com>2023-01-30 11:42:04 +0700
commitbd0731025377d5e8ebcbce78026698a57dea01df (patch)
treee3b365abc7a5b50483f94f3d742f141d9b2ee0bb /rq/types.py
parent398d5784db27ee7bc97fd2eb98aa5eb7d473d071 (diff)
downloadrq-bd0731025377d5e8ebcbce78026698a57dea01df.tar.gz
Job methods docstrings (#1772)
* Improve docstrings on `connections` * Enhanced Job methods docstrings & Serialization Protocol This adds docstrings to all Job methods in a standard format. It also implements a `serializer` protocol. * Excludes `Protocol` (keeping compatibility with < 3.8) * Add docstrings & type annotation to the `job` decorator * Docstrings for the `defaults` vars * Add deprecation warning to Connection context manager * Fix Types
Diffstat (limited to 'rq/types.py')
-rw-r--r--rq/types.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/rq/types.py b/rq/types.py
new file mode 100644
index 0000000..fe8e002
--- /dev/null
+++ b/rq/types.py
@@ -0,0 +1,17 @@
+from typing import TYPE_CHECKING, Any, Callable, List, TypeVar, Union
+
+if TYPE_CHECKING:
+ from .job import Dependency, Job
+
+
+FunctionReferenceType = TypeVar('FunctionReferenceType', str, Callable[..., Any])
+"""Custom type definition for what a `func` is in the context of a job.
+A `func` can be a string with the function import path (eg.: `myfile.mymodule.myfunc`)
+or a direct callable (function/method).
+"""
+
+
+JobDependencyType = TypeVar('JobDependencyType', 'Dependency', 'Job', str, List[Union['Dependency', 'Job']])
+"""Custom type definition for a job dependencies.
+A simple helper definition for the `depends_on` parameter when creating a job.
+"""