codekingpro/portable-devtools
114k
1"""Abstract base classes.2 3These are necessary to avoid circular imports between schema.py and fields.py.4 5.. warning::6 7 This module is deprecated. Users should not import from this module.8 Use `marshmallow.fields.Field` and `marshmallow.schema.Schema` as base classes instead.9"""10 11from __future__ import annotations12 13from abc import ABC, abstractmethod14 15 16class FieldABC(ABC):17 """Abstract base class from which all Field classes inherit."""18 19 @abstractmethod20 def serialize(self, attr, obj, accessor=None):21 pass22 23 @abstractmethod24 def deserialize(self, value):25 pass26 27 @abstractmethod28 def _serialize(self, value, attr, obj, **kwargs):29 pass30 31 @abstractmethod32 def _deserialize(self, value, attr, data, **kwargs):33 pass34 35 36class SchemaABC(ABC):37 """Abstract base class from which all Schemas inherit."""38 39 @abstractmethod40 def dump(self, obj, *, many: bool | None = None):41 pass42 43 @abstractmethod44 def dumps(self, obj, *, many: bool | None = None):45 pass46 47 @abstractmethod48 def load(self, data, *, many: bool | None = None, partial=None, unknown=None):49 pass50 51 @abstractmethod52 def loads(53 self,54 json_data,55 *,56 many: bool | None = None,57 partial=None,58 unknown=None,59 **kwargs,60 ):61 pass62 