marshmallow 3.24.2__py3-none-any.whl → 3.25.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
marshmallow/base.py CHANGED
@@ -4,8 +4,8 @@ These are necessary to avoid circular imports between schema.py and fields.py.
4
4
 
5
5
  .. warning::
6
6
 
7
- This module is treated as private API.
8
- Users should not need to use this module directly.
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
9
  """
10
10
 
11
11
  from __future__ import annotations
@@ -31,3 +31,31 @@ class FieldABC(ABC):
31
31
  @abstractmethod
32
32
  def _deserialize(self, value, attr, data, **kwargs):
33
33
  pass
34
+
35
+
36
+ class SchemaABC(ABC):
37
+ """Abstract base class from which all Schemas inherit."""
38
+
39
+ @abstractmethod
40
+ def dump(self, obj, *, many: bool | None = None):
41
+ pass
42
+
43
+ @abstractmethod
44
+ def dumps(self, obj, *, many: bool | None = None):
45
+ pass
46
+
47
+ @abstractmethod
48
+ def load(self, data, *, many: bool | None = None, partial=None, unknown=None):
49
+ pass
50
+
51
+ @abstractmethod
52
+ def loads(
53
+ self,
54
+ json_data,
55
+ *,
56
+ many: bool | None = None,
57
+ partial=None,
58
+ unknown=None,
59
+ **kwargs,
60
+ ):
61
+ pass
marshmallow/schema.py CHANGED
@@ -41,7 +41,7 @@ from marshmallow.utils import (
41
41
  from marshmallow.warnings import RemovedInMarshmallow4Warning
42
42
 
43
43
 
44
- def _get_fields(attrs):
44
+ def _get_fields(attrs) -> list[tuple[str, ma_fields.Field]]:
45
45
  """Get fields from a class
46
46
 
47
47
  :param attrs: Mapping of class attributes
@@ -124,10 +124,10 @@ class SchemaMeta(ABCMeta):
124
124
  def get_declared_fields(
125
125
  mcs,
126
126
  klass: SchemaMeta,
127
- cls_fields: list,
128
- inherited_fields: list,
127
+ cls_fields: list[tuple[str, ma_fields.Field]],
128
+ inherited_fields: list[tuple[str, ma_fields.Field]],
129
129
  dict_cls: type[dict] = dict,
130
- ):
130
+ ) -> dict[str, ma_fields.Field]:
131
131
  """Returns a dictionary of field_name => `Field` pairs declared on the class.
132
132
  This is exposed mainly so that plugins can add additional fields, e.g. fields
133
133
  computed from class Meta options.
@@ -231,7 +231,7 @@ class SchemaOpts:
231
231
  self.many = getattr(meta, "many", False)
232
232
 
233
233
 
234
- class Schema(metaclass=SchemaMeta):
234
+ class Schema(base.SchemaABC, metaclass=SchemaMeta):
235
235
  """Base schema class with which to define custom schemas.
236
236
 
237
237
  Example usage:
@@ -313,7 +313,7 @@ class Schema(metaclass=SchemaMeta):
313
313
  set_class = OrderedSet
314
314
 
315
315
  # These get set by SchemaMeta
316
- opts: SchemaOpts
316
+ opts: typing.Any
317
317
  _declared_fields: dict[str, ma_fields.Field] = {}
318
318
  _hooks: dict[str, list[tuple[str, bool, dict]]] = {}
319
319
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: marshmallow
3
- Version: 3.24.2
3
+ Version: 3.25.0
4
4
  Summary: A lightweight library for converting complex datatypes to and from native Python datatypes.
5
5
  Author-email: Steven Loria <sloria1@gmail.com>
6
6
  Maintainer-email: Steven Loria <sloria1@gmail.com>, Jérôme Lafréchoux <jerome@jolimont.fr>, Jared Deckard <jared@shademaps.com>
@@ -1,5 +1,5 @@
1
1
  marshmallow/__init__.py,sha256=C-zbaQJ9dlJLJxotIqTa5OOaD6ojGNRqW8moGrMsGr8,2387
2
- marshmallow/base.py,sha256=ty-JhN__qqlJHaFVrFjMJTM5hQH6pG3xeo82Zu0sweY,719
2
+ marshmallow/base.py,sha256=39W78-rnuzzx5T95YWBEECzjtqxdUA8XzYJNHd39VLg,1362
3
3
  marshmallow/class_registry.py,sha256=ZULbtwFxnj4bbzQqfwTLyNPUpr6xAZTLFMar4YJfKJQ,3032
4
4
  marshmallow/decorators.py,sha256=B8Z-PsxWrftY4jTq3y_wt7kwlJWQI2vVQQyApMY5IeQ,8490
5
5
  marshmallow/error_store.py,sha256=A7AxgLMw9ffSmaxRH4x3wcBWibx-DuGH4LwSDpVn50I,2223
@@ -7,12 +7,12 @@ marshmallow/exceptions.py,sha256=DuARdOcirCdJxmlp16V97hQKAXOokvdW12jXtYOlGyk,232
7
7
  marshmallow/fields.py,sha256=Z8wS9If4tqcv0KFnbm7HS5csMiVOD6--Donv6FlMfOc,74082
8
8
  marshmallow/orderedset.py,sha256=C2aAG6w1faIL1phinbAltbe3AUAnF5MN6n7fzESNDhI,2922
9
9
  marshmallow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- marshmallow/schema.py,sha256=EK_BHhjEk3ab8-3dlFZJ9RYim1B8LRwoUWJ4CHubi3I,48555
10
+ marshmallow/schema.py,sha256=qUY1MvcYxtEuztzjoom2fYaC7x2t16cAx4FBdgz3SDY,48696
11
11
  marshmallow/types.py,sha256=RDS4IfasIehvH2rGWh9e4RTBtsMp-JFFtjApajV22zc,283
12
12
  marshmallow/utils.py,sha256=pLZXqQWu7PHaQrQCrgwnR8eI_-aq_BVct5CCwyygUvk,11917
13
13
  marshmallow/validate.py,sha256=t5-4Qg_XlSQgcCujf_pimKIdZE0QT63jHyQP-miJNK0,24151
14
14
  marshmallow/warnings.py,sha256=YHC0kQQBbTKCiA1FuwnbnXqrph7oKuU9BjTV4cxwnzE,192
15
- marshmallow-3.24.2.dist-info/LICENSE,sha256=kGtdkFHkJhRMsXOtkRZnuOvQWpxYTCwmwTWzKj7RIAE,1064
16
- marshmallow-3.24.2.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
17
- marshmallow-3.24.2.dist-info/METADATA,sha256=tQkqTQ0CRseexhNURxf4oq1sEoD4hugcbSrvWqMO2DY,7084
18
- marshmallow-3.24.2.dist-info/RECORD,,
15
+ marshmallow-3.25.0.dist-info/LICENSE,sha256=kGtdkFHkJhRMsXOtkRZnuOvQWpxYTCwmwTWzKj7RIAE,1064
16
+ marshmallow-3.25.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
17
+ marshmallow-3.25.0.dist-info/METADATA,sha256=yQLETlmBAzADnSDY4fAT_4zsyjlAxPlRFT6NVIovaYo,7084
18
+ marshmallow-3.25.0.dist-info/RECORD,,