Spaces:
Sleeping
Sleeping
File size: 1,362 Bytes
dcbe3bf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
"""Abstract base classes.
These are necessary to avoid circular imports between schema.py and fields.py.
.. warning::
This module is deprecated. Users should not import from this module.
Use `marshmallow.fields.Field` and `marshmallow.schema.Schema` as base classes instead.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
class FieldABC(ABC):
"""Abstract base class from which all Field classes inherit."""
@abstractmethod
def serialize(self, attr, obj, accessor=None):
pass
@abstractmethod
def deserialize(self, value):
pass
@abstractmethod
def _serialize(self, value, attr, obj, **kwargs):
pass
@abstractmethod
def _deserialize(self, value, attr, data, **kwargs):
pass
class SchemaABC(ABC):
"""Abstract base class from which all Schemas inherit."""
@abstractmethod
def dump(self, obj, *, many: bool | None = None):
pass
@abstractmethod
def dumps(self, obj, *, many: bool | None = None):
pass
@abstractmethod
def load(self, data, *, many: bool | None = None, partial=None, unknown=None):
pass
@abstractmethod
def loads(
self,
json_data,
*,
many: bool | None = None,
partial=None,
unknown=None,
**kwargs,
):
pass
|