marshmallow 3.23.2__tar.gz → 3.24.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 (77) hide show
  1. {marshmallow-3.23.2 → marshmallow-3.24.0}/CHANGELOG.rst +38 -2
  2. {marshmallow-3.23.2 → marshmallow-3.24.0}/CONTRIBUTING.rst +11 -11
  3. {marshmallow-3.23.2 → marshmallow-3.24.0}/PKG-INFO +1 -2
  4. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/api_reference.rst +0 -10
  5. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/code_of_conduct.rst +12 -12
  6. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/conf.py +1 -21
  7. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/custom_fields.rst +8 -9
  8. marshmallow-3.24.0/docs/dashing.json +22 -0
  9. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/examples.rst +2 -2
  10. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/extending.rst +13 -20
  11. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/install.rst +2 -2
  12. marshmallow-3.24.0/docs/marshmallow.fields.rst +18 -0
  13. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/marshmallow.schema.rst +1 -0
  14. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/nesting.rst +6 -6
  15. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/quickstart.rst +18 -19
  16. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/upgrading.rst +14 -16
  17. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/why.rst +18 -18
  18. {marshmallow-3.23.2 → marshmallow-3.24.0}/pyproject.toml +4 -2
  19. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/base.py +0 -32
  20. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/class_registry.py +10 -0
  21. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/fields.py +129 -109
  22. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/schema.py +29 -35
  23. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/utils.py +1 -1
  24. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/validate.py +17 -9
  25. marshmallow-3.24.0/src/marshmallow/warnings.py +10 -0
  26. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/base.py +2 -3
  27. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_decorators.py +2 -2
  28. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_deserialization.py +26 -20
  29. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_fields.py +7 -7
  30. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_schema.py +126 -116
  31. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_serialization.py +15 -7
  32. marshmallow-3.23.2/docs/_static/css/versionwarning.css +0 -42
  33. marshmallow-3.23.2/docs/dashing.json +0 -22
  34. marshmallow-3.23.2/docs/marshmallow.fields.rst +0 -9
  35. marshmallow-3.23.2/src/marshmallow/warnings.py +0 -2
  36. {marshmallow-3.23.2 → marshmallow-3.24.0}/LICENSE +0 -0
  37. {marshmallow-3.23.2 → marshmallow-3.24.0}/NOTICE +0 -0
  38. {marshmallow-3.23.2 → marshmallow-3.24.0}/README.rst +0 -0
  39. {marshmallow-3.23.2 → marshmallow-3.24.0}/SECURITY.md +0 -0
  40. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/.gitignore +0 -0
  41. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/_static/marshmallow-logo.png +0 -0
  42. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/_templates/donate.html +0 -0
  43. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/_templates/useful-links.html +0 -0
  44. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/about.rst.inc +0 -0
  45. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/authors.rst +0 -0
  46. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/changelog.rst +0 -0
  47. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/contributing.rst +0 -0
  48. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/ecosystem.rst +0 -0
  49. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/index.rst +0 -0
  50. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/kudos.rst +0 -0
  51. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/license.rst +0 -0
  52. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/marshmallow.class_registry.rst +0 -0
  53. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/marshmallow.decorators.rst +0 -0
  54. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/marshmallow.error_store.rst +0 -0
  55. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/marshmallow.exceptions.rst +0 -0
  56. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/marshmallow.utils.rst +0 -0
  57. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/marshmallow.validate.rst +0 -0
  58. {marshmallow-3.23.2 → marshmallow-3.24.0}/docs/whos_using.rst +0 -0
  59. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/__init__.py +0 -0
  60. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/decorators.py +0 -0
  61. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/error_store.py +0 -0
  62. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/exceptions.py +0 -0
  63. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/orderedset.py +0 -0
  64. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/py.typed +0 -0
  65. {marshmallow-3.23.2 → marshmallow-3.24.0}/src/marshmallow/types.py +0 -0
  66. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/__init__.py +0 -0
  67. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/conftest.py +0 -0
  68. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/foo_serializer.py +0 -0
  69. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/mypy_test_cases/test_validation_error.py +0 -0
  70. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_error_store.py +0 -0
  71. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_exceptions.py +0 -0
  72. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_options.py +0 -0
  73. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_registry.py +0 -0
  74. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_utils.py +0 -0
  75. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_validate.py +0 -0
  76. {marshmallow-3.23.2 → marshmallow-3.24.0}/tests/test_version_attributes.py +0 -0
  77. {marshmallow-3.23.2 → marshmallow-3.24.0}/tox.ini +0 -0
@@ -1,6 +1,42 @@
1
1
  Changelog
2
2
  ---------
3
3
 
4
+ 3.24.0 (2025-01-06)
5
+ *******************
6
+
7
+ Features:
8
+
9
+ - Typing: Improve typings in `marshmallow.fields` (:pr:`2723`).
10
+ - Typing: Replace type comments with inline typings (:pr:`2718`).
11
+
12
+ Bug fixes:
13
+
14
+ - Typing: Fix type hint for ``nested`` parameter of `Nested <marshmallow.fields.Nested>`.
15
+
16
+ Deprecations:
17
+
18
+ - Custom validators should raise a `ValidationError <marshmallow.exceptions.ValidationError>` for invalid values.
19
+ Returning `False`` is no longer supported .
20
+ - Deprecate ``context`` parameter of `Schema <marshmallow.schema.Schema>` (:issue:`1826`).
21
+ Use `contextVars.ContextVar` to pass context data instead.
22
+ - `Field <marshmallow.fields.Field>`, `Mapping <marshmallow.fields.Mapping>`,
23
+ and `Number <marshmallow.fields.Number>` should no longer be used as fields within schemas.
24
+ Use their subclasses instead.
25
+
26
+
27
+ 3.23.3 (2025-01-03)
28
+ *******************
29
+
30
+ Bug fixes:
31
+
32
+ - Typing: Fix typing for `Schema.from_dict <marshmallow.schema.Schema.from_dict>` (:issue:`1653`).
33
+ Thanks :user:`SteadBytes` for reporting.
34
+
35
+ Support:
36
+
37
+ - Documentation: Various documentation cleanups, including more concise docs in the `marshmallow.fields` API reference (:issue:`2307`).
38
+ Thanks :user:`AbdealiLoKo` for reporting.
39
+
4
40
  3.23.2 (2024-12-18)
5
41
  *******************
6
42
 
@@ -1040,7 +1076,7 @@ Features:
1040
1076
  The ``strict`` parameter is removed.
1041
1077
  - *Backwards-incompatible*: ``Schema().load`` and ``Schema().dump`` return ``data`` instead of a
1042
1078
  ``(data, errors)`` tuple (:issue:`598`).
1043
- - *Backwards-incomaptible*: ``Schema().load(None)`` raises a
1079
+ - *Backwards-incompatible*: ``Schema().load(None)`` raises a
1044
1080
  ``ValidationError`` (:issue:`511`).
1045
1081
 
1046
1082
  See :ref:`upgrading_3_0` for a guide on updating your code.
@@ -1243,7 +1279,7 @@ Bug fixes:
1243
1279
  This is a backport of the fix in :pr:`857`. Thanks :user:`cristi23` for the
1244
1280
  thorough bug report and the PR.
1245
1281
 
1246
- Deprecation/Removal:
1282
+ Deprecation/Removals:
1247
1283
 
1248
1284
  - Python 2.6 is no longer officially supported (:issue:`1274`).
1249
1285
 
@@ -1,4 +1,4 @@
1
- Contributing Guidelines
1
+ Contributing guidelines
2
2
  =======================
3
3
 
4
4
  So you're interested in contributing to marshmallow or `one of our associated
@@ -7,21 +7,21 @@ welcome contributions from anyone willing to work in good faith with
7
7
  other contributors and the community (see also our
8
8
  :doc:`code_of_conduct`).
9
9
 
10
- Security Contact Information
10
+ Security contact information
11
11
  ----------------------------
12
12
 
13
13
  To report a security vulnerability, please use the
14
14
  `Tidelift security contact <https://tidelift.com/security>`_.
15
15
  Tidelift will coordinate the fix and disclosure.
16
16
 
17
- Questions, Feature Requests, Bug Reports, and Feedback
17
+ Questions, feature requests, bug reports, and feedback
18
18
  -------------------------------------------------------
19
19
 
20
20
  …should all be reported on the `Github Issue Tracker`_ .
21
21
 
22
22
  .. _`Github Issue Tracker`: https://github.com/marshmallow-code/marshmallow/issues?state=open
23
23
 
24
- Ways to Contribute
24
+ Ways to contribute
25
25
  ------------------
26
26
 
27
27
  - Comment on some of marshmallow's `open issues <https://github.com/marshmallow-code/marshmallow/issues>`_ (especially those `labeled "feedback welcome" <https://github.com/marshmallow-code/marshmallow/issues?q=is%3Aopen+is%3Aissue+label%3A%22feedback+welcome%22>`_). Share a solution or workaround. Make a suggestion for how a feature can be made better. Opinions are welcome!
@@ -34,10 +34,10 @@ Ways to Contribute
34
34
  - Send a PR for an open issue (especially one `labeled "help wanted" <https://github.com/marshmallow-code/marshmallow/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22>`_). The next section details how to contribute code.
35
35
 
36
36
 
37
- Contributing Code
37
+ Contributing code
38
38
  -----------------
39
39
 
40
- Setting Up for Local Development
40
+ Setting up for local development
41
41
  ++++++++++++++++++++++++++++++++
42
42
 
43
43
  1. Fork marshmallow_ on Github.
@@ -63,20 +63,20 @@ Setting Up for Local Development
63
63
  # The pre-commit CLI was installed above
64
64
  $ pre-commit install --allow-missing-config
65
65
 
66
- Git Branch Structure
66
+ Git branch structure
67
67
  ++++++++++++++++++++
68
68
 
69
- Marshmallow abides by the following branching model:
69
+ marshmallow abides by the following branching model:
70
70
 
71
71
  ``dev``
72
72
  Current development branch. **New features should branch off here**.
73
73
 
74
74
  ``X.Y-line``
75
- Maintenance branch for release ``X.Y``. **Bug fixes should be sent to the most recent release branch.** The maintainer will forward-port the fix to ``dev``. Note: exceptions may be made for bug fixes that introduce large code changes.
75
+ Maintenance branch for release ``X.Y``. **Bug fixes should be sent to the most recent release branch.** A maintainer will forward-port the fix to ``dev``. Note: exceptions may be made for bug fixes that introduce large code changes.
76
76
 
77
77
  **Always make a new branch for your work**, no matter how small. Also, **do not put unrelated changes in the same branch or pull request**. This makes it more difficult to merge your changes.
78
78
 
79
- Pull Requests
79
+ Pull requests
80
80
  ++++++++++++++
81
81
 
82
82
  1. Create a new local branch.
@@ -134,7 +134,7 @@ Changes in the `docs/` directory will automatically trigger a rebuild.
134
134
 
135
135
  .. _contributing_examples:
136
136
 
137
- Contributing Examples
137
+ Contributing examples
138
138
  +++++++++++++++++++++
139
139
 
140
140
  Have a usage example you'd like to share? A custom `Field` that others might find useful? Feel free to add it to the `examples <https://github.com/marshmallow-code/marshmallow/tree/dev/examples>`_ directory and send a pull request.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: marshmallow
3
- Version: 3.23.2
3
+ Version: 3.24.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>
@@ -22,7 +22,6 @@ Requires-Dist: pre-commit>=3.5,<5.0 ; extra == "dev"
22
22
  Requires-Dist: sphinx==8.1.3 ; extra == "docs"
23
23
  Requires-Dist: sphinx-issues==5.0.0 ; extra == "docs"
24
24
  Requires-Dist: alabaster==1.0.0 ; extra == "docs"
25
- Requires-Dist: sphinx-version-warning==1.1.2 ; extra == "docs"
26
25
  Requires-Dist: autodocsumm==0.2.14 ; extra == "docs"
27
26
  Requires-Dist: pytest ; extra == "tests"
28
27
  Requires-Dist: simplejson ; extra == "tests"
@@ -13,13 +13,3 @@ API Reference
13
13
  marshmallow.error_store
14
14
  marshmallow.class_registry
15
15
  marshmallow.exceptions
16
-
17
- .. automodule:: marshmallow
18
- :members:
19
- :undoc-members:
20
- :autosummary:
21
-
22
- .. data:: EXCLUDE
23
- .. data:: INCLUDE
24
- .. data:: RAISE
25
- .. data:: missing
@@ -8,7 +8,7 @@ organization.
8
8
 
9
9
  .. _coc-when-something-happens:
10
10
 
11
- When Something Happens
11
+ When something happens
12
12
  ----------------------
13
13
 
14
14
  If you see a Code of Conduct violation, follow these steps:
@@ -32,7 +32,7 @@ resolve the situation.
32
32
  recipients of the violation over the comfort of the violator.** See
33
33
  :ref:`some examples below <coc-enforcement-examples>`.
34
34
 
35
- Our Pledge
35
+ Our pledge
36
36
  ----------
37
37
 
38
38
  In the interest of fostering an open and welcoming environment, we as
@@ -43,7 +43,7 @@ identity and expression, level of experience, technical preferences,
43
43
  nationality, personal appearance, race, religion, or sexual identity and
44
44
  orientation.
45
45
 
46
- Our Standards
46
+ Our standards
47
47
  -------------
48
48
 
49
49
  Examples of behavior that contributes to creating a positive environment
@@ -112,7 +112,7 @@ to maintain the comfort and safety of its members.
112
112
 
113
113
  .. _coc-other-community-standards:
114
114
 
115
- Other Community Standards
115
+ Other community standards
116
116
  ~~~~~~~~~~~~~~~~~~~~~~~~~
117
117
 
118
118
  As a project on GitHub, this project is additionally covered by the
@@ -123,7 +123,7 @@ Enforcement of those guidelines after violations overlapping with the
123
123
  above are the responsibility of the entities, and enforcement may happen
124
124
  in any or all of the services/communities.
125
125
 
126
- Maintainer Enforcement Process
126
+ Maintainer enforcement process
127
127
  ------------------------------
128
128
 
129
129
  Once the maintainers get involved, they will follow a documented series
@@ -133,7 +133,7 @@ members. This section covers actual concrete steps.
133
133
 
134
134
  .. _coc-contacting-maintainers:
135
135
 
136
- Contacting Maintainers
136
+ Contacting maintainers
137
137
  ~~~~~~~~~~~~~~~~~~~~~~
138
138
 
139
139
  As a small and young project, we don't yet have a Code of Conduct
@@ -147,7 +147,7 @@ message is noticed quickly.
147
147
 
148
148
  .. _coc-further-enforcement:
149
149
 
150
- Further Enforcement
150
+ Further enforcement
151
151
  ~~~~~~~~~~~~~~~~~~~
152
152
 
153
153
  If you've already followed the :ref:`initial enforcement steps
@@ -177,7 +177,7 @@ in any social setting that puts our members at risk.
177
177
  Members expelled from events or venues with any sort of paid attendance
178
178
  will not be refunded.
179
179
 
180
- Who Watches the Watchers?
180
+ Who watches the watchers?
181
181
  ~~~~~~~~~~~~~~~~~~~~~~~~~
182
182
 
183
183
  Maintainers and other leaders who do not follow or enforce the Code of
@@ -194,10 +194,10 @@ procedures.
194
194
 
195
195
  .. _coc-enforcement-examples:
196
196
 
197
- Enforcement Examples
197
+ Enforcement examples
198
198
  --------------------
199
199
 
200
- The Best Case
200
+ The best case
201
201
  ~~~~~~~~~~~~~
202
202
 
203
203
  The vast majority of situations work out like this. This interaction is
@@ -211,7 +211,7 @@ common, and generally positive.
211
211
  Alex: "oh sorry, sure." -> edits old comment to say "it was really
212
212
  confusing!"
213
213
 
214
- The Maintainer Case
214
+ The maintainer case
215
215
  ~~~~~~~~~~~~~~~~~~~
216
216
 
217
217
  Sometimes, though, you need to get maintainers involved. Maintainers
@@ -248,7 +248,7 @@ something **will take priority**.
248
248
  KeeperOfCommitBits: "@patt Thanks for that. I hear you on the
249
249
  stress. Burnout sucks :/. Have a good one!"
250
250
 
251
- The Nope Case
251
+ The nope case
252
252
  ~~~~~~~~~~~~~
253
253
 
254
254
  PepeTheFrog🐸: "Hi, I am a literal actual nazi and I think white
@@ -8,14 +8,13 @@ extensions = [
8
8
  "sphinx.ext.viewcode",
9
9
  "alabaster",
10
10
  "sphinx_issues",
11
- "versionwarning.extension",
12
11
  "autodocsumm",
13
12
  ]
14
13
 
15
14
  primary_domain = "py"
16
15
  default_role = "py:obj"
17
16
 
18
- intersphinx_mapping = {"python": ("https://python.readthedocs.io/en/latest/", None)}
17
+ intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
19
18
 
20
19
  issues_github_path = "marshmallow-code/marshmallow"
21
20
 
@@ -36,7 +35,6 @@ exclude_patterns = ["_build"]
36
35
  html_theme_path = [alabaster.get_path()]
37
36
  html_theme = "alabaster"
38
37
  html_static_path = ["_static"]
39
- html_css_files = ["css/versionwarning.css"]
40
38
  templates_path = ["_templates"]
41
39
  html_show_sourcelink = False
42
40
 
@@ -76,21 +74,3 @@ html_sidebars = {
76
74
  "relations.html",
77
75
  ],
78
76
  }
79
-
80
- # sphinx-version-warning config
81
- versionwarning_messages = {
82
- "latest": (
83
- "This document is for the development version. "
84
- 'For the stable version documentation, see <a href="/en/stable/">here</a>.'
85
- ),
86
- "2.x-line": (
87
- "marshmallow 2 is no longer supported as of 2020-08-18. "
88
- '<a href="https://marshmallow.readthedocs.io/en/latest/upgrading.html#upgrading-to-3-0">'
89
- "Update your code to use marshmallow 3</a>."
90
- ),
91
- }
92
- # Show warning at top of page
93
- versionwarning_body_selector = "div.document"
94
- versionwarning_banner_title = ""
95
- # For debugging locally
96
- # versionwarning_project_version = "latest"
@@ -1,5 +1,4 @@
1
-
2
- Custom Fields
1
+ Custom fields
3
2
  =============
4
3
 
5
4
  There are three ways to create a custom-formatted field for a `Schema`:
@@ -10,7 +9,7 @@ There are three ways to create a custom-formatted field for a `Schema`:
10
9
 
11
10
  The method you choose will depend on the manner in which you intend to reuse the field.
12
11
 
13
- Creating A Field Class
12
+ Creating a field class
14
13
  ----------------------
15
14
 
16
15
  To create a custom field class, create a subclass of :class:`marshmallow.fields.Field` and implement its :meth:`_serialize <marshmallow.fields.Field._serialize>` and/or :meth:`_deserialize <marshmallow.fields.Field._deserialize>` methods.
@@ -43,7 +42,7 @@ To create a custom field class, create a subclass of :class:`marshmallow.fields.
43
42
  created_at = fields.DateTime()
44
43
  pin_code = PinCode()
45
44
 
46
- Method Fields
45
+ Method fields
47
46
  -------------
48
47
 
49
48
  A :class:`Method <marshmallow.fields.Method>` field will serialize to the value returned by a method of the Schema. The method must take an ``obj`` parameter which is the object to be serialized.
@@ -59,7 +58,7 @@ A :class:`Method <marshmallow.fields.Method>` field will serialize to the value
59
58
  def get_days_since_created(self, obj):
60
59
  return dt.datetime.now().day - obj.created_at.day
61
60
 
62
- Function Fields
61
+ Function fields
63
62
  ---------------
64
63
 
65
64
  A :class:`Function <marshmallow.fields.Function>` field will serialize the value of a function that is passed directly to it. Like a :class:`Method <marshmallow.fields.Method>` field, the function must take a single argument ``obj``.
@@ -97,7 +96,7 @@ Both :class:`Function <marshmallow.fields.Function>` and :class:`Method <marshma
97
96
 
98
97
  .. _adding-context:
99
98
 
100
- Adding Context to `Method` and `Function` Fields
99
+ Adding context to `Method` and `Function` fields
101
100
  ------------------------------------------------
102
101
 
103
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.
@@ -129,7 +128,7 @@ As an example, you might want your ``UserSchema`` to output whether or not a ``U
129
128
  result["likes_bikes"] # => True
130
129
 
131
130
 
132
- Customizing Error Messages
131
+ Customizing error messages
133
132
  --------------------------
134
133
 
135
134
  Validation error messages for fields can be configured at the class or instance level.
@@ -160,8 +159,8 @@ Error messages can also be passed to a `Field's` constructor.
160
159
  )
161
160
 
162
161
 
163
- Next Steps
162
+ Next steps
164
163
  ----------
165
164
 
166
- - Need to add schema-level validation, post-processing, or error handling behavior? See the :doc:`Extending Schemas <extending>` page.
165
+ - Need to add schema-level validation, post-processing, or error handling behavior? See the :doc:`Extending schemas <extending>` page.
167
166
  - For example applications using marshmallow, check out the :doc:`Examples <examples>` page.
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "marshmallow",
3
+ "package": "marshmallow",
4
+ "index": "_build/index.html",
5
+ "selectors": {
6
+ "dl.class dt": {
7
+ "type": "Class",
8
+ "attr": "id"
9
+ },
10
+ "dl.exception dt": {
11
+ "type": "Exception",
12
+ "attr": "id"
13
+ },
14
+ "dl.function dt": {
15
+ "type": "Function",
16
+ "attr": "id"
17
+ }
18
+ },
19
+ "icon32x32": "",
20
+ "allowJS": false,
21
+ "ExternalURL": ""
22
+ }
@@ -291,8 +291,8 @@ After registering a user and creating some todo items in the database, here is a
291
291
  }
292
292
 
293
293
 
294
- Inflection (Camel-casing Keys)
295
- ==============================
294
+ Inflection (camel-cased keys)
295
+ =============================
296
296
 
297
297
  HTTP APIs will often use camel-cased keys for their input and output representations. This example shows how you can use the
298
298
  `Schema.on_bind_field <marshmallow.Schema.on_bind_field>` hook to automatically inflect keys.
@@ -1,9 +1,9 @@
1
1
  .. module:: marshmallow
2
2
 
3
- Extending Schemas
3
+ Extending schemas
4
4
  =================
5
5
 
6
- Pre-processing and Post-processing Methods
6
+ Pre-processing and post-processing methods
7
7
  ------------------------------------------
8
8
 
9
9
  Data pre-processing and post-processing methods can be registered using 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>` decorators.
@@ -97,8 +97,7 @@ One common use case is to wrap data in a namespace upon serialization and unwrap
97
97
  user_objs = user_schema.load(users_data, many=True)
98
98
  # [<User(name='Keith Richards')>, <User(name='Charlie Watts')>]
99
99
 
100
-
101
- Raising Errors in Pre-/Post-processor Methods
100
+ Raising errors in pre-/post-processor methods
102
101
  +++++++++++++++++++++++++++++++++++++++++++++
103
102
 
104
103
  Pre- and post-processing methods may raise a `ValidationError <marshmallow.exceptions.ValidationError>`. By default, errors will be stored on the ``"_schema"`` key in the errors dictionary.
@@ -151,8 +150,7 @@ If you want to store and error on a different key, pass the key name as the seco
151
150
  err.messages
152
151
  # {'_preprocessing': ['Input data must have a "data" key.']}
153
152
 
154
-
155
- Pre-/Post-processor Invocation Order
153
+ Pre-/post-processor invocation order
156
154
  ++++++++++++++++++++++++++++++++++++
157
155
 
158
156
  In summary, the processing pipeline for deserialization is as follows:
@@ -215,10 +213,7 @@ The pipeline for serialization is similar, except that the ``pass_many=True`` pr
215
213
  def step2(self, data, **kwargs):
216
214
  do_step2(data)
217
215
 
218
-
219
- .. _schemavalidation:
220
-
221
- Schema-level Validation
216
+ Schema-level validation
222
217
  -----------------------
223
218
 
224
219
  You can register schema-level validation functions for a :class:`Schema` using the `marshmallow.validates_schema <marshmallow.decorators.validates_schema>` decorator. By default, schema-level validation errors will be stored on the ``_schema`` key of the errors dictionary.
@@ -245,7 +240,7 @@ You can register schema-level validation functions for a :class:`Schema` using t
245
240
  err.messages["_schema"]
246
241
  # => ["field_a must be greater than field_b"]
247
242
 
248
- Storing Errors on Specific Fields
243
+ Storing errors on specific fields
249
244
  +++++++++++++++++++++++++++++++++
250
245
 
251
246
  It is possible to report errors on fields and subfields using a `dict`.
@@ -300,8 +295,7 @@ When multiple schema-leval validator return errors, the error structures are mer
300
295
  # ]
301
296
  # }
302
297
 
303
-
304
- Using Original Input Data
298
+ Using original input data
305
299
  -------------------------
306
300
 
307
301
  If you want to use the original, unprocessed input, you can add ``pass_original=True`` to
@@ -332,7 +326,7 @@ If you want to use the original, unprocessed input, you can add ``pass_original=
332
326
 
333
327
  The default behavior for unspecified fields can be controlled with the ``unknown`` option, see :ref:`Handling Unknown Fields <unknown>` for more information.
334
328
 
335
- Overriding How Attributes Are Accessed
329
+ Overriding how attributes are accessed
336
330
  --------------------------------------
337
331
 
338
332
  By default, marshmallow uses `utils.get_value` to pull attributes from various types of objects for serialization. This will work for *most* use cases.
@@ -350,7 +344,7 @@ However, if you want to specify how values are accessed from an object, you can
350
344
  def get_attribute(self, obj, key, default):
351
345
  return obj.get(key, default)
352
346
 
353
- Custom Error Handling
347
+ Custom error handling
354
348
  ---------------------
355
349
 
356
350
  By default, :meth:`Schema.load` will raise a :exc:`ValidationError <marshmallow.exceptions.ValidationError>` if passed invalid data.
@@ -379,15 +373,14 @@ You can specify a custom error-handling function for a :class:`Schema` by overri
379
373
  schema = UserSchema()
380
374
  schema.load({"email": "invalid-email"}) # raises AppError
381
375
 
382
-
383
- Custom "class Meta" Options
376
+ Custom "class Meta" options
384
377
  ---------------------------
385
378
 
386
379
  ``class Meta`` options are a way to configure and modify a :class:`Schema's <Schema>` behavior. See the :class:`API docs <Schema.Meta>` for a listing of available options.
387
380
 
388
381
  You can add custom ``class Meta`` options by subclassing :class:`SchemaOpts`.
389
382
 
390
- Example: Enveloping, Revisited
383
+ Example: Enveloping, revisited
391
384
  ++++++++++++++++++++++++++++++
392
385
 
393
386
  Let's build upon the example above for adding an envelope to serialized output. This time, we will allow the envelope key to be customizable with ``class Meta`` options.
@@ -461,7 +454,7 @@ Our application schemas can now inherit from our custom schema class.
461
454
  result = ser.dump(user)
462
455
  result # {"user": {"name": "Keith", "email": "keith@stones.com"}}
463
456
 
464
- Using Context
457
+ Using context
465
458
  -------------
466
459
 
467
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.
@@ -474,7 +467,7 @@ The ``context`` attribute of a `Schema` is a general-purpose store for extra inf
474
467
  schema.context["request"] = request
475
468
  schema.dump(user)
476
469
 
477
- Custom Error Messages
470
+ Custom error messages
478
471
  ---------------------
479
472
 
480
473
  To customize the schema-level error messages that `load <marshmallow.Schema.load>` and `loads <marshmallow.Schema.loads>` use when raising a `ValidationError <marshmallow.exceptions.ValidationError>`, override the `error_messages <marshmallow.Schema.error_messages>` class variable:
@@ -5,7 +5,7 @@ Installation
5
5
 
6
6
  **marshmallow** has no external dependencies other than the `packaging` library.
7
7
 
8
- Installing/Upgrading from the PyPI
8
+ Installing/upgrading from the PyPI
9
9
  ----------------------------------
10
10
 
11
11
  To install the latest stable version from the PyPI:
@@ -20,7 +20,7 @@ To install the latest pre-release version from the PyPI:
20
20
 
21
21
  $ pip install -U marshmallow --pre
22
22
 
23
- Get the Bleeding Edge Version
23
+ Get the bleeding edge version
24
24
  -----------------------------
25
25
 
26
26
  To get the latest development version of marshmallow, run
@@ -0,0 +1,18 @@
1
+ .. _api_fields:
2
+
3
+ Fields
4
+ ======
5
+
6
+ Base Field Class
7
+ ----------------
8
+
9
+ .. autoclass:: marshmallow.fields.Field
10
+ :private-members:
11
+
12
+ Field subclasses
13
+ ----------------
14
+
15
+ .. automodule:: marshmallow.fields
16
+ :members:
17
+ :autosummary:
18
+ :exclude-members: Field, default_error_messages, mapping_type, num_type, DESERIALIZATION_CLASS
@@ -4,5 +4,6 @@ Schema
4
4
  .. autoclass:: marshmallow.schema.Schema
5
5
  :inherited-members:
6
6
  :autosummary:
7
+ :exclude-members: OPTIONS_CLASS
7
8
 
8
9
  .. autoclass:: marshmallow.schema.SchemaOpts
@@ -1,4 +1,4 @@
1
- Nesting Schemas
1
+ Nesting schemas
2
2
  ===============
3
3
 
4
4
  Schemas can be nested to represent relationships between objects (e.g. foreign key relationships). For example, a ``Blog`` may have an author represented by a User object.
@@ -63,7 +63,7 @@ The serialized blog will have the nested user representation.
63
63
 
64
64
  .. _specifying-nested-fields:
65
65
 
66
- Specifying Which Fields to Nest
66
+ Specifying which fields to nest
67
67
  -------------------------------
68
68
 
69
69
  You can explicitly specify which attributes of the nested objects you want to (de)serialize with the ``only`` argument to the schema.
@@ -129,7 +129,7 @@ You can replace nested data with a single value (or flat list of values if ``man
129
129
 
130
130
  .. _partial-loading:
131
131
 
132
- Partial Loading
132
+ Partial loading
133
133
  ---------------
134
134
 
135
135
  Nested schemas also inherit the ``partial`` parameter of the parent ``load`` call.
@@ -165,7 +165,7 @@ You can specify a subset of the fields to allow partial loading using dot delimi
165
165
 
166
166
  .. _two-way-nesting:
167
167
 
168
- Two-way Nesting
168
+ Two-way nesting
169
169
  ---------------
170
170
 
171
171
  If you have two objects that nest each other, you can pass a callable to `Nested <marshmallow.fields.Nested>`.
@@ -258,7 +258,7 @@ This is useful for avoiding circular imports when your schemas are located in di
258
258
 
259
259
  .. _self-nesting:
260
260
 
261
- Nesting A Schema Within Itself
261
+ Nesting a schema within itself
262
262
  ------------------------------
263
263
 
264
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.
@@ -303,7 +303,7 @@ If the object to be marshalled has a relationship to an object of the same type,
303
303
  # }
304
304
  # }
305
305
 
306
- Next Steps
306
+ Next steps
307
307
  ----------
308
308
 
309
309
  - Want to create your own field type? See the :doc:`Custom Fields <custom_fields>` page.