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/serializers.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/serializers.py')
-rw-r--r-- | rq/serializers.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/rq/serializers.py b/rq/serializers.py index 00fd0a7..9e63bc7 100644 --- a/rq/serializers.py +++ b/rq/serializers.py @@ -1,6 +1,7 @@ from functools import partial import pickle import json +from typing import Optional, Union from .utils import import_attribute @@ -20,11 +21,17 @@ class JSONSerializer(): return json.loads(s.decode('utf-8'), *args, **kwargs) -def resolve_serializer(serializer: str): +def resolve_serializer(serializer=None): """This function checks the user defined serializer for ('dumps', 'loads') methods It returns a default pickle serializer if not found else it returns a MySerializer The returned serializer objects implement ('dumps', 'loads') methods - Also accepts a string path to serializer that will be loaded as the serializer + Also accepts a string path to serializer that will be loaded as the serializer. + + Args: + serializer (Callable): The serializer to resolve. + + Returns: + serializer (Callable): An object that implements the SerializerProtocol """ if not serializer: return DefaultSerializer |