marshmallow 3.24.1__tar.gz → 3.25.0__tar.gz

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.
Files changed (76) hide show
  1. {marshmallow-3.24.1 → marshmallow-3.25.0}/CHANGELOG.rst +36 -3
  2. {marshmallow-3.24.1 → marshmallow-3.25.0}/PKG-INFO +1 -1
  3. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/api_reference.rst +1 -0
  4. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/custom_fields.rst +2 -2
  5. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/examples.rst +1 -3
  6. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/extending.rst +4 -4
  7. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/nesting.rst +1 -1
  8. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/quickstart.rst +6 -8
  9. marshmallow-3.25.0/docs/top_level.rst +12 -0
  10. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/upgrading.rst +31 -31
  11. {marshmallow-3.24.1 → marshmallow-3.25.0}/pyproject.toml +1 -1
  12. marshmallow-3.25.0/src/marshmallow/base.py +61 -0
  13. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/decorators.py +5 -5
  14. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/fields.py +28 -36
  15. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/schema.py +11 -11
  16. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/utils.py +1 -1
  17. marshmallow-3.24.1/src/marshmallow/base.py +0 -33
  18. {marshmallow-3.24.1 → marshmallow-3.25.0}/CONTRIBUTING.rst +0 -0
  19. {marshmallow-3.24.1 → marshmallow-3.25.0}/LICENSE +0 -0
  20. {marshmallow-3.24.1 → marshmallow-3.25.0}/NOTICE +0 -0
  21. {marshmallow-3.24.1 → marshmallow-3.25.0}/README.rst +0 -0
  22. {marshmallow-3.24.1 → marshmallow-3.25.0}/SECURITY.md +0 -0
  23. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/.gitignore +0 -0
  24. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/_static/marshmallow-logo.png +0 -0
  25. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/_templates/donate.html +0 -0
  26. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/_templates/useful-links.html +0 -0
  27. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/about.rst.inc +0 -0
  28. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/authors.rst +0 -0
  29. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/changelog.rst +0 -0
  30. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/code_of_conduct.rst +0 -0
  31. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/conf.py +0 -0
  32. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/contributing.rst +0 -0
  33. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/dashing.json +0 -0
  34. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/ecosystem.rst +0 -0
  35. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/index.rst +0 -0
  36. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/install.rst +0 -0
  37. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/kudos.rst +0 -0
  38. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/license.rst +0 -0
  39. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/marshmallow.class_registry.rst +0 -0
  40. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/marshmallow.decorators.rst +0 -0
  41. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/marshmallow.error_store.rst +0 -0
  42. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/marshmallow.exceptions.rst +0 -0
  43. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/marshmallow.fields.rst +0 -0
  44. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/marshmallow.schema.rst +0 -0
  45. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/marshmallow.utils.rst +0 -0
  46. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/marshmallow.validate.rst +0 -0
  47. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/whos_using.rst +0 -0
  48. {marshmallow-3.24.1 → marshmallow-3.25.0}/docs/why.rst +0 -0
  49. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/__init__.py +0 -0
  50. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/class_registry.py +0 -0
  51. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/error_store.py +0 -0
  52. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/exceptions.py +0 -0
  53. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/orderedset.py +0 -0
  54. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/py.typed +0 -0
  55. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/types.py +0 -0
  56. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/validate.py +0 -0
  57. {marshmallow-3.24.1 → marshmallow-3.25.0}/src/marshmallow/warnings.py +0 -0
  58. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/__init__.py +0 -0
  59. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/base.py +0 -0
  60. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/conftest.py +0 -0
  61. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/foo_serializer.py +0 -0
  62. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/mypy_test_cases/test_class_registry.py +0 -0
  63. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/mypy_test_cases/test_validation_error.py +0 -0
  64. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_decorators.py +0 -0
  65. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_deserialization.py +0 -0
  66. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_error_store.py +0 -0
  67. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_exceptions.py +0 -0
  68. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_fields.py +0 -0
  69. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_options.py +0 -0
  70. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_registry.py +0 -0
  71. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_schema.py +0 -0
  72. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_serialization.py +0 -0
  73. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_utils.py +0 -0
  74. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_validate.py +0 -0
  75. {marshmallow-3.24.1 → marshmallow-3.25.0}/tests/test_version_attributes.py +0 -0
  76. {marshmallow-3.24.1 → marshmallow-3.25.0}/tox.ini +0 -0
@@ -1,6 +1,39 @@
1
1
  Changelog
2
2
  ---------
3
3
 
4
+ 3.25.0 (2025-01-09)
5
+ *******************
6
+
7
+ Features:
8
+
9
+ - Typing: Improve type annotations for ``SchemaMeta.get_declared_fields`` (:pr:`2742`).
10
+
11
+ Bug fixes:
12
+
13
+ - Typing: Relax type annotation for ``Schema.opts`` to allow subclasses to define their own
14
+ options classes (:pr:`2744`).
15
+
16
+ Other changes:
17
+
18
+ - Restore ``marshmallow.base.SchemaABC`` for backwards-compatibility (:issue:`2743`).
19
+ Note that this class is deprecated and will be removed in marshmallow 4.
20
+ Use `marshmallow.schema.Schema` as a base class for type-checking instead.
21
+
22
+ 3.24.2 (2025-01-08)
23
+ *******************
24
+
25
+ Changes:
26
+
27
+ - Don't override ``__new__`` to avoid breaking usages of `inspect.signature` with
28
+ `Field <marshmallow.fields.Field>` classes.
29
+ This allows marshmallow-sqlalchemy users to upgrade marshmallow without
30
+ upgrading to marshmallow-sqlalchemy>=1.1.1.
31
+
32
+ Documentation:
33
+
34
+ - Add top-level API back to docs (:issue:`2739`).
35
+ Thanks :user:`llucax` for reporting.
36
+
4
37
  3.24.1 (2025-01-06)
5
38
  *******************
6
39
 
@@ -22,7 +55,7 @@ Bug fixes:
22
55
 
23
56
  Deprecations:
24
57
 
25
- - Custom validators should raise a `ValidationError <marshmallow.exceptions.ValidationError>` for invalid values.
58
+ - Custom validators should raise a `ValidationError <marshmallow.exceptions.ValidationError>` for invalid values.
26
59
  Returning `False`` is no longer supported .
27
60
  - Deprecate ``context`` parameter of `Schema <marshmallow.schema.Schema>` (:issue:`1826`).
28
61
  Use `contextVars.ContextVar` to pass context data instead.
@@ -295,7 +328,7 @@ Bug fixes:
295
328
  - Don't expose ``Field``\s as ``Schema`` attributes. This reverts a change
296
329
  introduced in 3.12.0 that causes issues when field names conflict with
297
330
  ``Schema`` attributes or methods. ``Fields``\s are still accessible on a
298
- ``Schema`` instance through the ``fields`` attribute. (:pr:`1843`)
331
+ ``Schema`` instance through the ``fields`` attribute. (:pr:`1843`)
299
332
 
300
333
  3.12.1 (2021-05-10)
301
334
  *******************
@@ -870,7 +903,7 @@ Bug fixes:
870
903
  Other changes:
871
904
 
872
905
  - *Backwards-incompatible*: ``_serialize`` and ``_deserialize`` methods of
873
- all ``fields.Field`` subclasses must accept ``**kwargs`` (:pr:`1007`).
906
+ all ``fields.Field`` subclasses must accept ``**kwargs`` (:pr:`1007`).
874
907
 
875
908
 
876
909
  3.0.0b18 (2018-10-15)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: marshmallow
3
- Version: 3.24.1
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>
@@ -5,6 +5,7 @@ API Reference
5
5
  *************
6
6
 
7
7
  .. toctree::
8
+ top_level
8
9
  marshmallow.schema
9
10
  marshmallow.fields
10
11
  marshmallow.decorators
@@ -1,7 +1,7 @@
1
1
  Custom fields
2
2
  =============
3
3
 
4
- There are three ways to create a custom-formatted field for a `Schema`:
4
+ There are three ways to create a custom-formatted field for a `Schema <marshmallow.Schema>`:
5
5
 
6
6
  - Create a custom :class:`Field <marshmallow.fields.Field>` class
7
7
  - Use a :class:`Method <marshmallow.fields.Method>` field
@@ -101,7 +101,7 @@ Adding context to `Method` and `Function` fields
101
101
 
102
102
  A :class:`Function <marshmallow.fields.Function>` or :class:`Method <marshmallow.fields.Method>` field may need information about its environment to know how to serialize a value.
103
103
 
104
- In these cases, you can set the ``context`` attribute (a dictionary) of a `Schema`. :class:`Function <marshmallow.fields.Function>` and :class:`Method <marshmallow.fields.Method>` fields will have access to this dictionary.
104
+ In these cases, you can set the ``context`` attribute (a dictionary) of a `Schema <marshmallow.Schema>`. :class:`Function <marshmallow.fields.Function>` and :class:`Method <marshmallow.fields.Method>` fields will have access to this dictionary.
105
105
 
106
106
  As an example, you might want your ``UserSchema`` to output whether or not a ``User`` is the author of a ``Blog`` or whether a certain word appears in a ``Blog's`` title.
107
107
 
@@ -1,5 +1,3 @@
1
- .. module:: marshmallow
2
-
3
1
  ********
4
2
  Examples
5
3
  ********
@@ -12,7 +10,7 @@ Below is a schema that could be used to validate
12
10
  ``package.json`` files. This example demonstrates the following features:
13
11
 
14
12
 
15
- - Validation and deserialization using :meth:`Schema.load`
13
+ - Validation and deserialization using `Schema.load <marshmallow.Schema.load>`
16
14
  - :doc:`Custom fields <custom_fields>`
17
15
  - Specifying deserialization keys using ``data_key``
18
16
  - Including unknown keys using ``unknown = INCLUDE``
@@ -1,5 +1,3 @@
1
- .. module:: marshmallow
2
-
3
1
  Extending schemas
4
2
  =================
5
3
 
@@ -213,6 +211,8 @@ The pipeline for serialization is similar, except that the ``pass_many=True`` pr
213
211
  def step2(self, data, **kwargs):
214
212
  do_step2(data)
215
213
 
214
+ .. _schema_validation:
215
+
216
216
  Schema-level validation
217
217
  -----------------------
218
218
 
@@ -347,7 +347,7 @@ However, if you want to specify how values are accessed from an object, you can
347
347
  Custom error handling
348
348
  ---------------------
349
349
 
350
- By default, :meth:`Schema.load` will raise a :exc:`ValidationError <marshmallow.exceptions.ValidationError>` if passed invalid data.
350
+ By default, `Schema.load <marshmallow.Schema.load>` will raise a :exc:`ValidationError <marshmallow.exceptions.ValidationError>` if passed invalid data.
351
351
 
352
352
  You can specify a custom error-handling function for a :class:`Schema` by overriding the `handle_error <marshmallow.Schema.handle_error>` method. The method receives the :exc:`ValidationError <marshmallow.exceptions.ValidationError>` and the original input data to be deserialized.
353
353
 
@@ -457,7 +457,7 @@ Our application schemas can now inherit from our custom schema class.
457
457
  Using context
458
458
  -------------
459
459
 
460
- The ``context`` attribute of a `Schema` is a general-purpose store for extra information that may be needed for (de)serialization. It may be used in both ``Schema`` and ``Field`` methods.
460
+ The ``context`` attribute of a `Schema <marshmallow.Schema>` is a general-purpose store for extra information that may be needed for (de)serialization. It may be used in both ``Schema`` and ``Field`` methods.
461
461
 
462
462
  .. code-block:: python
463
463
 
@@ -261,7 +261,7 @@ This is useful for avoiding circular imports when your schemas are located in di
261
261
  Nesting a schema within itself
262
262
  ------------------------------
263
263
 
264
- If the object to be marshalled has a relationship to an object of the same type, you can nest the `Schema` within itself by passing a callable that returns an instance of the same schema.
264
+ If the object to be marshalled has a relationship to an object of the same type, you can nest the `Schema <marshmallow.Schema>` within itself by passing a callable that returns an instance of the same schema.
265
265
 
266
266
  .. code-block:: python
267
267
 
@@ -1,5 +1,3 @@
1
- .. module:: marshmallow
2
-
3
1
  Quickstart
4
2
  ==========
5
3
 
@@ -176,7 +174,7 @@ Set ``many=True`` when dealing with iterable collections of objects.
176
174
  Validation
177
175
  ----------
178
176
 
179
- :meth:`Schema.load` (and its JSON-decoding counterpart, :meth:`Schema.loads`) raises a :exc:`ValidationError <marshmallow.exceptions.ValidationError>` error when invalid data are passed in. You can access the dictionary of validation errors from the `ValidationError.messages <marshmallow.exceptions.ValidationError.messages>` attribute. The data that were correctly deserialized are accessible in `ValidationError.valid_data <marshmallow.exceptions.ValidationError.valid_data>`. Some fields, such as the :class:`Email <fields.Email>` and :class:`URL <fields.URL>` fields, have built-in validation.
177
+ `Schema.load <marshmallow.Schema.load>` (and its JSON-decoding counterpart, `Schema.loads <marshmallow.Schema.loads>`) raises a :exc:`ValidationError <marshmallow.exceptions.ValidationError>` error when invalid data are passed in. You can access the dictionary of validation errors from the `ValidationError.messages <marshmallow.exceptions.ValidationError.messages>` attribute. The data that were correctly deserialized are accessible in `ValidationError.valid_data <marshmallow.exceptions.ValidationError.valid_data>`. Some fields, such as the :class:`Email <fields.Email>` and :class:`URL <fields.URL>` fields, have built-in validation.
180
178
 
181
179
  .. code-block:: python
182
180
 
@@ -275,7 +273,7 @@ You may also pass a collection (list, tuple, generator) of callables to ``valida
275
273
  .. warning::
276
274
 
277
275
  Validation occurs on deserialization but not on serialization.
278
- To improve serialization performance, data passed to :meth:`Schema.dump`
276
+ To improve serialization performance, data passed to `Schema.dump <marshmallow.Schema.dump>`
279
277
  are considered valid.
280
278
 
281
279
  .. seealso::
@@ -286,7 +284,7 @@ You may also pass a collection (list, tuple, generator) of callables to ``valida
286
284
 
287
285
  .. seealso::
288
286
 
289
- Need schema-level validation? See the :ref:`Extending Schemas <schemavalidation>` page.
287
+ Need schema-level validation? See the :ref:`Extending Schemas <schema_validation>` page.
290
288
 
291
289
 
292
290
  Field validators as methods
@@ -313,7 +311,7 @@ It is sometimes convenient to write validators as methods. Use the `validates <m
313
311
  Required fields
314
312
  ---------------
315
313
 
316
- Make a field required by passing ``required=True``. An error will be raised if the the value is missing from the input to :meth:`Schema.load`.
314
+ Make a field required by passing ``required=True``. An error will be raised if the the value is missing from the input to `Schema.load <marshmallow.Schema.load>`.
317
315
 
318
316
  To customize the error message for required fields, pass a `dict` with a ``required`` key as the ``error_messages`` argument for the field.
319
317
 
@@ -405,7 +403,7 @@ This behavior can be modified with the ``unknown`` option, which accepts one of
405
403
  - `EXCLUDE <marshmallow.utils.EXCLUDE>`: exclude unknown fields
406
404
  - `INCLUDE <marshmallow.utils.INCLUDE>`: accept and include the unknown fields
407
405
 
408
- You can specify ``unknown`` in the *class Meta* of your `Schema`,
406
+ You can specify ``unknown`` in the *class Meta* of your `Schema <marshmallow.Schema>`,
409
407
 
410
408
  .. code-block:: python
411
409
 
@@ -436,7 +434,7 @@ This order of precedence allows you to change the behavior of a schema for diffe
436
434
  Validation without deserialization
437
435
  ----------------------------------
438
436
 
439
- If you only need to validate input data (without deserializing to an object), you can use :meth:`Schema.validate`.
437
+ If you only need to validate input data (without deserializing to an object), you can use `Schema.validate <marshmallow.Schema.validate>`.
440
438
 
441
439
  .. code-block:: python
442
440
 
@@ -0,0 +1,12 @@
1
+ Top-level API
2
+ =============
3
+
4
+ .. automodule:: marshmallow
5
+ :members:
6
+ :undoc-members:
7
+ :autosummary:
8
+
9
+ .. data:: EXCLUDE
10
+ .. data:: INCLUDE
11
+ .. data:: RAISE
12
+ .. data:: missing
@@ -6,7 +6,7 @@ This section documents migration paths to new releases.
6
6
  Upgrading to 3.3
7
7
  ++++++++++++++++
8
8
 
9
- In 3.3, `fields.Nested <marshmallow.fields.Nested>` may take a callable that returns a schema instance.
9
+ In 3.3, `fields.Nested <marshmallow.fields.Nested>` may take a callable that returns a schema instance.
10
10
  Use this to resolve order-of-declaration issues when schemas nest each other.
11
11
 
12
12
  .. code-block:: python
@@ -103,15 +103,15 @@ along with the valid data from the `ValidationError.valid_data
103
103
  errors = err.messages
104
104
  valid_data = err.valid_data
105
105
 
106
- :meth:`Schema.validate() <marshmallow.Schema.validate>` always returns a dictionary of validation errors (same as 2.x with ``strict=False``).
106
+ `Schema.validate <marshmallow.Schema.validate>` always returns a dictionary of validation errors (same as 2.x with ``strict=False``).
107
107
 
108
108
  .. code-block:: python
109
109
 
110
110
  schema.validate({"email": "invalid"})
111
111
  # {'email': ['Not a valid email address.']}
112
112
 
113
- Setting the ``strict`` option on ``class Meta`` has no effect on `Schema` behavior.
114
- Passing ``strict=True`` or ``strict=False`` to the `Schema` constructor
113
+ Setting the ``strict`` option on ``class Meta`` has no effect on `Schema <marshmallow.Schema>` behavior.
114
+ Passing ``strict=True`` or ``strict=False`` to the `Schema <marshmallow.Schema>` constructor
115
115
  will raise a :exc:`TypeError`.
116
116
 
117
117
 
@@ -182,7 +182,7 @@ and `validates_schema <marshmallow.decorators.validates_schema>` receive
182
182
  Validation does not occur on serialization
183
183
  ******************************************
184
184
 
185
- :meth:`Schema.dump() <marshmallow.Schema.dump>` will no longer validate and collect error messages. You *must* validate
185
+ `Schema.dump <marshmallow.Schema.dump>` will no longer validate and collect error messages. You *must* validate
186
186
  your data before serializing it.
187
187
 
188
188
  .. code-block:: python
@@ -737,7 +737,7 @@ The same key is used for serialization and deserialization.
737
737
  email = fields.Email(data_key="CamelCasedEmail")
738
738
 
739
739
  It is not possible to specify a different key for serialization and deserialization on the same field.
740
- This use case is covered by using two different `Schema`.
740
+ This use case is covered by using two different `Schema <marshmallow.Schema>`.
741
741
 
742
742
  .. code-block:: python
743
743
 
@@ -970,8 +970,8 @@ The ``prefix`` parameter of ``Schema`` is removed. The same feature can be achie
970
970
 
971
971
  # 2.x
972
972
  class MySchema(Schema):
973
- f1 = fields.Field()
974
- f2 = fields.Field()
973
+ f1 = fields.Raw()
974
+ f2 = fields.Raw()
975
975
 
976
976
 
977
977
  MySchema(prefix="pre_").dump({"f1": "one", "f2": "two"})
@@ -980,8 +980,8 @@ The ``prefix`` parameter of ``Schema`` is removed. The same feature can be achie
980
980
 
981
981
  # 3.x
982
982
  class MySchema(Schema):
983
- f1 = fields.Field()
984
- f2 = fields.Field()
983
+ f1 = fields.Raw()
984
+ f2 = fields.Raw()
985
985
 
986
986
  @post_dump
987
987
  def prefix_usr(self, data):
@@ -1025,10 +1025,10 @@ In marshmallow 2, it was possible to have multiple fields with the same ``attrib
1025
1025
 
1026
1026
  # 2.x
1027
1027
  class MySchema(Schema):
1028
- f1 = fields.Field()
1029
- f2 = fields.Field(attribute="f1")
1030
- f3 = fields.Field(attribute="f5")
1031
- f4 = fields.Field(attribute="f5")
1028
+ f1 = fields.Raw()
1029
+ f2 = fields.Raw(attribute="f1")
1030
+ f3 = fields.Raw(attribute="f5")
1031
+ f4 = fields.Raw(attribute="f5")
1032
1032
 
1033
1033
 
1034
1034
  MySchema()
@@ -1037,10 +1037,10 @@ In marshmallow 2, it was possible to have multiple fields with the same ``attrib
1037
1037
 
1038
1038
  # 3.x
1039
1039
  class MySchema(Schema):
1040
- f1 = fields.Field()
1041
- f2 = fields.Field(attribute="f1")
1042
- f3 = fields.Field(attribute="f5")
1043
- f4 = fields.Field(attribute="f5")
1040
+ f1 = fields.Raw()
1041
+ f2 = fields.Raw(attribute="f1")
1042
+ f3 = fields.Raw(attribute="f5")
1043
+ f4 = fields.Raw(attribute="f5")
1044
1044
 
1045
1045
 
1046
1046
  MySchema()
@@ -1048,10 +1048,10 @@ In marshmallow 2, it was possible to have multiple fields with the same ``attrib
1048
1048
 
1049
1049
 
1050
1050
  class MySchema(Schema):
1051
- f1 = fields.Field()
1052
- f2 = fields.Field(attribute="f1", dump_only=True)
1053
- f3 = fields.Field(attribute="f5")
1054
- f4 = fields.Field(attribute="f5", dump_only=True)
1051
+ f1 = fields.Raw()
1052
+ f2 = fields.Raw(attribute="f1", dump_only=True)
1053
+ f3 = fields.Raw(attribute="f5")
1054
+ f4 = fields.Raw(attribute="f5", dump_only=True)
1055
1055
 
1056
1056
 
1057
1057
  MySchema()
@@ -1061,7 +1061,7 @@ In marshmallow 2, it was possible to have multiple fields with the same ``attrib
1061
1061
  ``Field.fail`` is deprecated in favor of ``Field.make_error``
1062
1062
  *************************************************************
1063
1063
 
1064
- `Field.fail <marshmallow.fields.Field.fail>` is deprecated.
1064
+ `Field.fail <marshmallow.fields.Field.fail>` is deprecated.
1065
1065
  Use `Field.make_error <marshmallow.fields.Field.fail>`. This allows you to
1066
1066
  re-raise exceptions using ``raise ... from ...``.
1067
1067
 
@@ -1242,7 +1242,7 @@ As a consequence of this new behavior, the ``skip_missing`` class Meta option ha
1242
1242
  Pre-processing and post-processing methods
1243
1243
  ******************************************
1244
1244
 
1245
- The pre- and post-processing API was significantly improved for better consistency and flexibility. The `pre_load <marshmallow.decorators.pre_load>`, `post_load <marshmallow.decorators.post_load>`, `pre_dump <marshmallow.decorators.pre_dump>`, and `post_dump <marshmallow.decorators.post_dump>` should be used to define processing hooks. `Schema.preprocessor` and `Schema.data_handler` are removed.
1245
+ The pre- and post-processing API was significantly improved for better consistency and flexibility. The `pre_load <marshmallow.decorators.pre_load>`, `post_load <marshmallow.decorators.post_load>`, `pre_dump <marshmallow.decorators.pre_dump>`, and `post_dump <marshmallow.decorators.post_dump>` should be used to define processing hooks. ``Schema.preprocessor`` and ``Schema.data_handler`` are removed.
1246
1246
 
1247
1247
 
1248
1248
  .. code-block:: python
@@ -1289,7 +1289,7 @@ See the :doc:`Extending Schemas <extending>` page for more information on the ``
1289
1289
  Schema validators
1290
1290
  *****************
1291
1291
 
1292
- Similar to pre-processing and post-processing methods, schema validators are now defined as methods. Decorate schema validators with `validates_schema <marshmallow.decorators.validates_schema>`. `Schema.validator` is removed.
1292
+ Similar to pre-processing and post-processing methods, schema validators are now defined as methods. Decorate schema validators with `validates_schema <marshmallow.decorators.validates_schema>`. ``Schema.validator`` is removed.
1293
1293
 
1294
1294
  .. code-block:: python
1295
1295
 
@@ -1324,7 +1324,7 @@ Similar to pre-processing and post-processing methods, schema validators are now
1324
1324
  Custom accessors and error handlers
1325
1325
  ***********************************
1326
1326
 
1327
- Custom accessors and error handlers are now defined as methods. `Schema.accessor` and `Schema.error_handler` are deprecated.
1327
+ Custom accessors and error handlers are now defined as methods. ``Schema.accessor`` and ``Schema.error_handler`` are deprecated.
1328
1328
 
1329
1329
  .. code-block:: python
1330
1330
 
@@ -1432,7 +1432,7 @@ The :exc:`MarshallingError` and :exc:`UnmarshallingError` exceptions are depreca
1432
1432
  Handle ``ValidationError`` in strict mode
1433
1433
  -----------------------------------------
1434
1434
 
1435
- When using `strict` mode, you should handle `ValidationErrors` when calling `Schema.dump` and `Schema.load`.
1435
+ When using `strict` mode, you should handle `ValidationErrors` when calling `Schema.dump <marshmallow.Schema.dump>` and `Schema.load <marshmallow.Schema.load>`.
1436
1436
 
1437
1437
  .. code-block:: python
1438
1438
 
@@ -1707,7 +1707,7 @@ Perhaps the largest change is in how objects get serialized. Serialization occur
1707
1707
 
1708
1708
  .. note::
1709
1709
 
1710
- Some crucial parts of the pre-1.0 API have been retained to ease the transition. You can still pass an object to a `Schema` constructor and access the `Schema.data` and `Schema.errors` properties. The `is_valid` method, however, has been completely removed. It is recommended that you migrate to the new API to prevent future releases from breaking your code.
1710
+ Some crucial parts of the pre-1.0 API have been retained to ease the transition. You can still pass an object to a `Schema <marshmallow.Schema>` constructor and access the `Schema.data` and `Schema.errors` properties. The `is_valid` method, however, has been completely removed. It is recommended that you migrate to the new API to prevent future releases from breaking your code.
1711
1711
 
1712
1712
  The Fields interface was also reworked in 1.0 to make it easier to define custom fields with their own serialization and deserialization behavior. Custom fields now implement :meth:`Field._serialize` and :meth:`Field._deserialize`.
1713
1713
 
@@ -1753,11 +1753,11 @@ Another major change in 1.0 is that multiple validation errors can be stored for
1753
1753
 
1754
1754
  Other notable changes:
1755
1755
 
1756
- - Serialized output is no longer an `OrderedDict` by default. You must explicitly set the `ordered` class Meta option to `True` .
1757
- - :class:`Serializer` has been renamed to :class:`Schema`, but you can still import `marshmallow.Serializer` (which is aliased to :class:`Schema`).
1756
+ - Serialized output is no longer an ``OrderedDict`` by default. You must explicitly set the `ordered` class Meta option to `True` .
1757
+ - ``Serializer`` has been renamed to `Schema <marshmallow.schema.Schema>`, but you can still import ``marshmallow.Serializer`` (which is aliased to `Schema <marshmallow.Schema>`).
1758
1758
  - ``datetime`` objects serialize to ISO8601-formatted strings by default (instead of RFC821 format).
1759
1759
  - The ``fields.validated`` decorator was removed, as it is no longer necessary given the new Fields interface.
1760
- - `Schema.factory` class method was removed.
1760
+ - ``Schema.factory`` class method was removed.
1761
1761
 
1762
1762
  .. seealso::
1763
1763
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "marshmallow"
3
- version = "3.24.1"
3
+ version = "3.25.0"
4
4
  description = "A lightweight library for converting complex datatypes to and from native Python datatypes."
5
5
  readme = "README.rst"
6
6
  license = { file = "LICENSE" }
@@ -0,0 +1,61 @@
1
+ """Abstract base classes.
2
+
3
+ These 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
+
11
+ from __future__ import annotations
12
+
13
+ from abc import ABC, abstractmethod
14
+
15
+
16
+ class FieldABC(ABC):
17
+ """Abstract base class from which all Field classes inherit."""
18
+
19
+ @abstractmethod
20
+ def serialize(self, attr, obj, accessor=None):
21
+ pass
22
+
23
+ @abstractmethod
24
+ def deserialize(self, value):
25
+ pass
26
+
27
+ @abstractmethod
28
+ def _serialize(self, value, attr, obj, **kwargs):
29
+ pass
30
+
31
+ @abstractmethod
32
+ def _deserialize(self, value, attr, data, **kwargs):
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
@@ -100,7 +100,7 @@ def validates_schema(
100
100
  """Register a schema-level validator.
101
101
 
102
102
  By default it receives a single object at a time, transparently handling the ``many``
103
- argument passed to the `Schema`'s :func:`~marshmallow.Schema.validate` call.
103
+ argument passed to the `Schema <marshmallow.Schema>`'s :func:`~marshmallow.Schema.validate` call.
104
104
  If ``pass_many=True``, the raw data (which may be a collection) is passed.
105
105
 
106
106
  If ``pass_original=True``, the original data (before unmarshalling) will be passed as
@@ -132,7 +132,7 @@ def pre_dump(
132
132
  receives the object to be serialized and returns the processed object.
133
133
 
134
134
  By default it receives a single object at a time, transparently handling the ``many``
135
- argument passed to the `Schema`'s :func:`~marshmallow.Schema.dump` call.
135
+ argument passed to the `Schema <marshmallow.Schema>`'s :func:`~marshmallow.Schema.dump` call.
136
136
  If ``pass_many=True``, the raw data (which may be a collection) is passed.
137
137
 
138
138
  .. versionchanged:: 3.0.0
@@ -150,7 +150,7 @@ def post_dump(
150
150
  receives the serialized object and returns the processed object.
151
151
 
152
152
  By default it receives a single object at a time, transparently handling the ``many``
153
- argument passed to the `Schema`'s :func:`~marshmallow.Schema.dump` call.
153
+ argument passed to the `Schema <marshmallow.Schema>`'s :func:`~marshmallow.Schema.dump` call.
154
154
  If ``pass_many=True``, the raw data (which may be a collection) is passed.
155
155
 
156
156
  If ``pass_original=True``, the original data (before serializing) will be passed as
@@ -169,7 +169,7 @@ def pre_load(
169
169
  receives the data to be deserialized and returns the processed data.
170
170
 
171
171
  By default it receives a single object at a time, transparently handling the ``many``
172
- argument passed to the `Schema`'s :func:`~marshmallow.Schema.load` call.
172
+ argument passed to the `Schema <marshmallow.Schema>`'s :func:`~marshmallow.Schema.load` call.
173
173
  If ``pass_many=True``, the raw data (which may be a collection) is passed.
174
174
 
175
175
  .. versionchanged:: 3.0.0
@@ -188,7 +188,7 @@ def post_load(
188
188
  receives the deserialized data and returns the processed data.
189
189
 
190
190
  By default it receives a single object at a time, transparently handling the ``many``
191
- argument passed to the `Schema`'s :func:`~marshmallow.Schema.load` call.
191
+ argument passed to the `Schema <marshmallow.Schema>`'s :func:`~marshmallow.Schema.load` call.
192
192
  If ``pass_many=True``, the raw data (which may be a collection) is passed.
193
193
 
194
194
  If ``pass_original=True``, the original data (before deserializing) will be passed as
@@ -139,16 +139,6 @@ class Field(FieldABC):
139
139
  "validator_failed": "Invalid value.",
140
140
  }
141
141
 
142
- def __new__(cls, *args, **kwargs):
143
- if cls is Field:
144
- warnings.warn(
145
- "`Field` should not be instantiated. Use `fields.Raw` or "
146
- "another field subclass instead.",
147
- ChangedInMarshmallow4Warning,
148
- stacklevel=2,
149
- )
150
- return super().__new__(cls)
151
-
152
142
  def __init__(
153
143
  self,
154
144
  *,
@@ -171,6 +161,13 @@ class Field(FieldABC):
171
161
  metadata: typing.Mapping[str, typing.Any] | None = None,
172
162
  **additional_metadata,
173
163
  ) -> None:
164
+ if self.__class__ is Field:
165
+ warnings.warn(
166
+ "`Field` should not be instantiated. Use `fields.Raw` or "
167
+ "another field subclass instead.",
168
+ ChangedInMarshmallow4Warning,
169
+ stacklevel=2,
170
+ )
174
171
  # handle deprecated `default` and `missing` parameters
175
172
  if default is not missing_:
176
173
  warnings.warn(
@@ -361,7 +358,7 @@ class Field(FieldABC):
361
358
 
362
359
  :param value: The value to deserialize.
363
360
  :param attr: The attribute/key in `data` to deserialize.
364
- :param data: The raw input data passed to `Schema.load`.
361
+ :param data: The raw input data passed to `Schema.load <marshmallow.Schema.load>`.
365
362
  :param kwargs: Field-specific keyword arguments.
366
363
  :raise ValidationError: If an invalid value is passed or if a required value
367
364
  is missing.
@@ -382,7 +379,7 @@ class Field(FieldABC):
382
379
 
383
380
  def _bind_to_schema(self, field_name: str, schema: Schema | Field) -> None:
384
381
  """Update field with values from its parent schema. Called by
385
- :meth:`Schema._bind_field <marshmallow.Schema._bind_field>`.
382
+ `Schema._bind_field <marshmallow.Schema._bind_field>`.
386
383
 
387
384
  :param str field_name: Field name set in schema.
388
385
  :param Schema|Field schema: Parent object.
@@ -426,7 +423,7 @@ class Field(FieldABC):
426
423
 
427
424
  :param value: The value to be deserialized.
428
425
  :param attr: The attribute/key in `data` to be deserialized.
429
- :param data: The raw input data passed to the `Schema.load`.
426
+ :param data: The raw input data passed to the `Schema.load <marshmallow.Schema.load>`.
430
427
  :param kwargs: Field-specific keyword arguments.
431
428
  :raise ValidationError: In case of formatting or validation failure.
432
429
  :return: The deserialized value.
@@ -440,7 +437,7 @@ class Field(FieldABC):
440
437
 
441
438
  @property
442
439
  def context(self) -> dict | None:
443
- """The context dictionary for the parent :class:`Schema`."""
440
+ """The context dictionary for the parent `Schema <marshmallow.Schema>`."""
444
441
  if self.parent:
445
442
  return self.parent.context
446
443
  return None
@@ -527,8 +524,9 @@ class Nested(Field):
527
524
  # No
528
525
  author = fields.Nested(UserSchema(), only=("id", "name"))
529
526
 
530
- :param nested: `Schema` instance, class, class name (string), dictionary, or callable that
531
- returns a `Schema` or dictionary. Dictionaries are converted with `Schema.from_dict`.
527
+ :param nested: `Schema <marshmallow.Schema>` instance, class, class name (string), dictionary, or callable that
528
+ returns a `Schema <marshmallow.Schema>` or dictionary.
529
+ Dictionaries are converted with `Schema.from_dict <marshmallow.Schema.from_dict>`.
532
530
  :param exclude: A list or tuple of fields to exclude.
533
531
  :param only: A list or tuple of fields to marshal. If `None`, all fields are marshalled.
534
532
  This parameter takes precedence over ``exclude``.
@@ -583,10 +581,10 @@ class Nested(Field):
583
581
 
584
582
  @property
585
583
  def schema(self) -> Schema:
586
- """The nested Schema object.
584
+ """The nested `Schema <marshmallow.Schema>` object.
587
585
 
588
586
  .. versionchanged:: 1.0.0
589
- Renamed from `serializer` to `schema`.
587
+ Renamed from ``serializer`` to ``schema``.
590
588
  """
591
589
  if not self._schema:
592
590
  # Inherit context from parent.
@@ -681,8 +679,8 @@ class Nested(Field):
681
679
  ) -> typing.Any:
682
680
  """Same as :meth:`Field._deserialize` with additional ``partial`` argument.
683
681
 
684
- :param bool|tuple partial: For nested schemas, the ``partial``
685
- parameter passed to `Schema.load`.
682
+ :param partial: For nested schemas, the ``partial``
683
+ parameter passed to `marshmallow.Schema.load`.
686
684
 
687
685
  .. versionchanged:: 3.0.0
688
686
  Add ``partial`` parameter.
@@ -713,7 +711,7 @@ class Pluck(Nested):
713
711
  dumped = AlbumSchema().dump(loaded) # => {'artist': 42}
714
712
 
715
713
  :param Schema nested: The Schema class or class name (string)
716
- to nest, or ``"self"`` to nest the :class:`Schema` within itself.
714
+ to nest, or ``"self"`` to nest the `Schema <marshmallow.Schema>` within itself.
717
715
  :param str field_name: The key to pluck a value from.
718
716
  :param kwargs: The same keyword arguments that :class:`Nested` receives.
719
717
  """
@@ -962,16 +960,13 @@ class Number(Field, typing.Generic[_NumType]):
962
960
  "too_large": "Number too large.",
963
961
  }
964
962
 
965
- def __new__(cls, *args, **kwargs):
966
- if cls is Number:
963
+ def __init__(self, *, as_string: bool = False, **kwargs):
964
+ if self.__class__ is Number:
967
965
  warnings.warn(
968
966
  "`Number` field should not be instantiated. Use `Integer`, `Float`, or `Decimal` instead.",
969
967
  ChangedInMarshmallow4Warning,
970
968
  stacklevel=2,
971
969
  )
972
- return super().__new__(cls)
973
-
974
- def __init__(self, *, as_string: bool = False, **kwargs):
975
970
  self.as_string = as_string
976
971
  super().__init__(**kwargs)
977
972
 
@@ -1578,21 +1573,18 @@ class Mapping(Field):
1578
1573
  #: Default error messages.
1579
1574
  default_error_messages = {"invalid": "Not a valid mapping type."}
1580
1575
 
1581
- def __new__(cls, *args, **kwargs):
1582
- if cls is Mapping:
1583
- warnings.warn(
1584
- "`Mapping` field should not be instantiated. Use `Dict` instead.",
1585
- ChangedInMarshmallow4Warning,
1586
- stacklevel=2,
1587
- )
1588
- return super().__new__(cls)
1589
-
1590
1576
  def __init__(
1591
1577
  self,
1592
1578
  keys: Field | type[Field] | None = None,
1593
1579
  values: Field | type[Field] | None = None,
1594
1580
  **kwargs,
1595
1581
  ):
1582
+ if self.__class__ is Mapping:
1583
+ warnings.warn(
1584
+ "`Mapping` field should not be instantiated. Use `Dict` instead.",
1585
+ ChangedInMarshmallow4Warning,
1586
+ stacklevel=2,
1587
+ )
1596
1588
  super().__init__(**kwargs)
1597
1589
  if keys is None:
1598
1590
  self.key_field = None
@@ -1965,7 +1957,7 @@ class Enum(Field):
1965
1957
 
1966
1958
 
1967
1959
  class Method(Field):
1968
- """A field that takes the value returned by a `Schema` method.
1960
+ """A field that takes the value returned by a `Schema <marshmallow.Schema>` method.
1969
1961
 
1970
1962
  :param str serialize: The name of the Schema method from which
1971
1963
  to retrieve the value. The method must take an argument ``obj``
@@ -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
 
@@ -344,15 +344,15 @@ class Schema(metaclass=SchemaMeta):
344
344
  - ``timeformat``: Default format for `Time <fields.Time>` fields.
345
345
  - ``render_module``: Module to use for `loads <Schema.loads>` and `dumps <Schema.dumps>`.
346
346
  Defaults to `json` from the standard library.
347
- - ``ordered``: If `True`, output of `Schema.dump` will be a `collections.OrderedDict`.
347
+ - ``ordered``: If `True`, output of `Schema.dump <marshmallow.Schema.dump>` will be a `collections.OrderedDict`.
348
348
  - ``index_errors``: If `True`, errors dictionaries will include the index
349
349
  of invalid items in a collection.
350
350
  - ``load_only``: Tuple or list of fields to exclude from serialized results.
351
351
  - ``dump_only``: Tuple or list of fields to exclude from deserialization
352
352
  - ``unknown``: Whether to exclude, include, or raise an error for unknown
353
353
  fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
354
- - ``register``: Whether to register the `Schema` with marshmallow's internal
355
- class registry. Must be `True` if you intend to refer to this `Schema`
354
+ - ``register``: Whether to register the `Schema <marshmallow.Schema>` with marshmallow's internal
355
+ class registry. Must be `True` if you intend to refer to this `Schema <marshmallow.Schema>`
356
356
  by class name in `Nested` fields. Only set this to `False` when memory
357
357
  usage is critical. Defaults to `True`.
358
358
  """
@@ -428,7 +428,7 @@ class Schema(metaclass=SchemaMeta):
428
428
  *,
429
429
  name: str = "GeneratedSchema",
430
430
  ) -> type[Schema]:
431
- """Generate a `Schema` class given a dictionary of fields.
431
+ """Generate a `Schema <marshmallow.Schema>` class given a dictionary of fields.
432
432
 
433
433
  .. code-block:: python
434
434
 
@@ -1016,7 +1016,7 @@ class Schema(metaclass=SchemaMeta):
1016
1016
  self.load_fields = load_fields
1017
1017
 
1018
1018
  def on_bind_field(self, field_name: str, field_obj: ma_fields.Field) -> None:
1019
- """Hook to modify a field when it is bound to the `Schema`.
1019
+ """Hook to modify a field when it is bound to the `Schema <marshmallow.Schema>`.
1020
1020
 
1021
1021
  No-op by default.
1022
1022
  """
@@ -39,7 +39,7 @@ class _Missing:
39
39
 
40
40
 
41
41
  # Singleton value that indicates that a field's value is missing from input
42
- # dict passed to :meth:`Schema.load`. If the field's value is not required,
42
+ # dict passed to `Schema.load <marshmallow.Schema.load>`. If the field's value is not required,
43
43
  # it's ``default`` value is used.
44
44
  missing = _Missing()
45
45
 
@@ -1,33 +0,0 @@
1
- """Abstract base classes.
2
-
3
- These are necessary to avoid circular imports between schema.py and fields.py.
4
-
5
- .. warning::
6
-
7
- This module is treated as private API.
8
- Users should not need to use this module directly.
9
- """
10
-
11
- from __future__ import annotations
12
-
13
- from abc import ABC, abstractmethod
14
-
15
-
16
- class FieldABC(ABC):
17
- """Abstract base class from which all Field classes inherit."""
18
-
19
- @abstractmethod
20
- def serialize(self, attr, obj, accessor=None):
21
- pass
22
-
23
- @abstractmethod
24
- def deserialize(self, value):
25
- pass
26
-
27
- @abstractmethod
28
- def _serialize(self, value, attr, obj, **kwargs):
29
- pass
30
-
31
- @abstractmethod
32
- def _deserialize(self, value, attr, data, **kwargs):
33
- pass
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes