diff options
author | lowercase00 <21188280+lowercase00@users.noreply.github.com> | 2023-01-30 01:42:04 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-30 11:42:04 +0700 |
commit | bd0731025377d5e8ebcbce78026698a57dea01df (patch) | |
tree | e3b365abc7a5b50483f94f3d742f141d9b2ee0bb /rq/types.py | |
parent | 398d5784db27ee7bc97fd2eb98aa5eb7d473d071 (diff) | |
download | rq-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.py | 17 |
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. +""" |