diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2022-07-31 20:34:27 +0300 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2022-07-31 23:51:50 +0300 |
commit | 4c785354a5ec342ca1796cbd0a0098d6e093a48e (patch) | |
tree | a1ead25a78ea4702ae1f0071a9904933873c79ac /src/apscheduler/serializers | |
parent | e5d0aa1828b834ebc7d2c4dca6b49063ad951ef4 (diff) | |
download | apscheduler-4c785354a5ec342ca1796cbd0a0098d6e093a48e.tar.gz |
Added missing docstrings to classes
Diffstat (limited to 'src/apscheduler/serializers')
-rw-r--r-- | src/apscheduler/serializers/cbor.py | 11 | ||||
-rw-r--r-- | src/apscheduler/serializers/json.py | 13 | ||||
-rw-r--r-- | src/apscheduler/serializers/pickle.py | 12 |
3 files changed, 36 insertions, 0 deletions
diff --git a/src/apscheduler/serializers/cbor.py b/src/apscheduler/serializers/cbor.py index 9791b77..fa2b29d 100644 --- a/src/apscheduler/serializers/cbor.py +++ b/src/apscheduler/serializers/cbor.py @@ -11,6 +11,17 @@ from ..marshalling import marshal_object, unmarshal_object @attrs.define(kw_only=True, eq=False) class CBORSerializer(Serializer): + """ + Serializes objects using CBOR (:rfc:`8949`). + + Can serialize types not normally CBOR serializable, if they implement + ``__getstate__()`` and ``__setstate__()``. + + :param type_tag: CBOR tag number for indicating arbitrary serialized object + :param dump_options: keyword arguments passed to :func:`cbor2.dumps` + :param load_options: keyword arguments passed to :func:`cbor2.loads` + """ + type_tag: int = 4664 dump_options: dict[str, Any] = attrs.field(factory=dict) load_options: dict[str, Any] = attrs.field(factory=dict) diff --git a/src/apscheduler/serializers/json.py b/src/apscheduler/serializers/json.py index 21f8bc2..2fd25fd 100644 --- a/src/apscheduler/serializers/json.py +++ b/src/apscheduler/serializers/json.py @@ -13,6 +13,19 @@ from ..marshalling import marshal_date, marshal_object, unmarshal_object @attrs.define(kw_only=True, eq=False) class JSONSerializer(Serializer): + """ + Serializes objects using JSON. + + Can serialize types not normally CBOR serializable, if they implement + ``__getstate__()`` and ``__setstate__()``. These objects are serialized into dicts + that contain the necessary information for deserialization in ``magic_key``. + + :param magic_key: name of a specially handled dict key that indicates that a dict + contains a serialized instance of an arbitrary type + :param dump_options: keyword arguments passed to :func:`json.dumps` + :param load_options: keyword arguments passed to :func:`json.loads` + """ + magic_key: str = "_apscheduler_json" dump_options: dict[str, Any] = attrs.field(factory=dict) load_options: dict[str, Any] = attrs.field(factory=dict) diff --git a/src/apscheduler/serializers/pickle.py b/src/apscheduler/serializers/pickle.py index 5edf2d0..8c5a022 100644 --- a/src/apscheduler/serializers/pickle.py +++ b/src/apscheduler/serializers/pickle.py @@ -9,6 +9,18 @@ from ..abc import Serializer @attrs.define(kw_only=True, eq=False) class PickleSerializer(Serializer): + """ + Uses the :mod:`pickle` module to (de)serialize objects. + + As this serialization method is native to Python, it is able to serialize a wide + range of types, at the expense of being insecure. Do **not** use this serializer + unless you can fully trust the entire system to not have maliciously injected data. + Such data can be made to call arbitrary functions with arbitrary arguments on + unpickling. + + :param protocol: the pickle protocol number to use + """ + protocol: int = 4 def serialize(self, obj) -> bytes: |