marshmallow 3.23.2__tar.gz → 3.23.3__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 (75) hide show
  1. {marshmallow-3.23.2 → marshmallow-3.23.3}/CHANGELOG.rst +13 -0
  2. {marshmallow-3.23.2 → marshmallow-3.23.3}/PKG-INFO +1 -2
  3. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/api_reference.rst +0 -10
  4. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/conf.py +1 -21
  5. marshmallow-3.23.3/docs/marshmallow.fields.rst +18 -0
  6. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/marshmallow.schema.rst +1 -0
  7. {marshmallow-3.23.2 → marshmallow-3.23.3}/pyproject.toml +1 -2
  8. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/fields.py +6 -39
  9. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/schema.py +3 -18
  10. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/utils.py +1 -1
  11. marshmallow-3.23.2/docs/_static/css/versionwarning.css +0 -42
  12. marshmallow-3.23.2/docs/marshmallow.fields.rst +0 -9
  13. {marshmallow-3.23.2 → marshmallow-3.23.3}/CONTRIBUTING.rst +0 -0
  14. {marshmallow-3.23.2 → marshmallow-3.23.3}/LICENSE +0 -0
  15. {marshmallow-3.23.2 → marshmallow-3.23.3}/NOTICE +0 -0
  16. {marshmallow-3.23.2 → marshmallow-3.23.3}/README.rst +0 -0
  17. {marshmallow-3.23.2 → marshmallow-3.23.3}/SECURITY.md +0 -0
  18. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/.gitignore +0 -0
  19. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/_static/marshmallow-logo.png +0 -0
  20. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/_templates/donate.html +0 -0
  21. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/_templates/useful-links.html +0 -0
  22. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/about.rst.inc +0 -0
  23. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/authors.rst +0 -0
  24. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/changelog.rst +0 -0
  25. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/code_of_conduct.rst +0 -0
  26. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/contributing.rst +0 -0
  27. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/custom_fields.rst +0 -0
  28. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/dashing.json +0 -0
  29. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/ecosystem.rst +0 -0
  30. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/examples.rst +0 -0
  31. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/extending.rst +0 -0
  32. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/index.rst +0 -0
  33. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/install.rst +0 -0
  34. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/kudos.rst +0 -0
  35. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/license.rst +0 -0
  36. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/marshmallow.class_registry.rst +0 -0
  37. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/marshmallow.decorators.rst +0 -0
  38. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/marshmallow.error_store.rst +0 -0
  39. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/marshmallow.exceptions.rst +0 -0
  40. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/marshmallow.utils.rst +0 -0
  41. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/marshmallow.validate.rst +0 -0
  42. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/nesting.rst +0 -0
  43. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/quickstart.rst +0 -0
  44. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/upgrading.rst +0 -0
  45. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/whos_using.rst +0 -0
  46. {marshmallow-3.23.2 → marshmallow-3.23.3}/docs/why.rst +0 -0
  47. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/__init__.py +0 -0
  48. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/base.py +0 -0
  49. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/class_registry.py +0 -0
  50. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/decorators.py +0 -0
  51. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/error_store.py +0 -0
  52. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/exceptions.py +0 -0
  53. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/orderedset.py +0 -0
  54. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/py.typed +0 -0
  55. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/types.py +0 -0
  56. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/validate.py +0 -0
  57. {marshmallow-3.23.2 → marshmallow-3.23.3}/src/marshmallow/warnings.py +0 -0
  58. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/__init__.py +0 -0
  59. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/base.py +0 -0
  60. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/conftest.py +0 -0
  61. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/foo_serializer.py +0 -0
  62. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/mypy_test_cases/test_validation_error.py +0 -0
  63. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_decorators.py +0 -0
  64. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_deserialization.py +0 -0
  65. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_error_store.py +0 -0
  66. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_exceptions.py +0 -0
  67. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_fields.py +0 -0
  68. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_options.py +0 -0
  69. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_registry.py +0 -0
  70. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_schema.py +0 -0
  71. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_serialization.py +0 -0
  72. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_utils.py +0 -0
  73. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_validate.py +0 -0
  74. {marshmallow-3.23.2 → marshmallow-3.23.3}/tests/test_version_attributes.py +0 -0
  75. {marshmallow-3.23.2 → marshmallow-3.23.3}/tox.ini +0 -0
@@ -1,6 +1,19 @@
1
1
  Changelog
2
2
  ---------
3
3
 
4
+ 3.23.3 (2025-01-03)
5
+ *******************
6
+
7
+ Bug fixes:
8
+
9
+ - Typing: Fix typing for `Schema.from_dict <marshmallow.schema.Schema.from_dict>` (:issue:`1653`).
10
+ Thanks :user:`SteadBytes` for reporting.
11
+
12
+ Support:
13
+
14
+ - Documentation: Various documentation cleanups, including more concise docs in the `marshmallow.fields` API reference (:issue:`2307`).
15
+ Thanks :user:`AbdealiLoKo` for reporting.
16
+
4
17
  3.23.2 (2024-12-18)
5
18
  *******************
6
19
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: marshmallow
3
- Version: 3.23.2
3
+ Version: 3.23.3
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,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"
@@ -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,6 +1,6 @@
1
1
  [project]
2
2
  name = "marshmallow"
3
- version = "3.23.2"
3
+ version = "3.23.3"
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" }
@@ -36,7 +36,6 @@ docs = [
36
36
  "sphinx==8.1.3",
37
37
  "sphinx-issues==5.0.0",
38
38
  "alabaster==1.0.0",
39
- "sphinx-version-warning==1.1.2",
40
39
  "autodocsumm==0.2.14",
41
40
  ]
42
41
  tests = ["pytest", "simplejson"]
@@ -1,5 +1,3 @@
1
- """Field classes for various types of data."""
2
-
3
1
  from __future__ import annotations
4
2
 
5
3
  import collections
@@ -84,7 +82,6 @@ class Field(FieldABC):
84
82
  """Basic field from which other fields should extend. It applies no
85
83
  formatting by default, and should only be used in cases where
86
84
  data does not need to be formatted before being serialized or deserialized.
87
- On error, the name of the field will be returned.
88
85
 
89
86
  :param dump_default: If set, this value will be used during serialization if the
90
87
  input value is missing. If not set, the field will be excluded from the
@@ -108,8 +105,9 @@ class Field(FieldABC):
108
105
  :param required: Raise a :exc:`ValidationError` if the field value
109
106
  is not supplied during deserialization.
110
107
  :param allow_none: Set this to `True` if `None` should be considered a valid value during
111
- validation/deserialization. If ``load_default=None`` and ``allow_none`` is unset,
112
- will default to ``True``. Otherwise, the default is ``False``.
108
+ validation/deserialization. If set to `False` (the default), `None` is considered invalid input.
109
+ If ``load_default`` is explicitly set to `None` and ``allow_none`` is unset,
110
+ `allow_none` is implicitly set to ``True``.
113
111
  :param load_only: If `True` skip this field during serialization, otherwise
114
112
  its value will be present in the serialized data.
115
113
  :param dump_only: If `True` skip this field during deserialization, otherwise
@@ -118,28 +116,12 @@ class Field(FieldABC):
118
116
  :param dict error_messages: Overrides for `Field.default_error_messages`.
119
117
  :param metadata: Extra information to be stored as field metadata.
120
118
 
121
- .. versionchanged:: 2.0.0
122
- Removed `error` parameter. Use ``error_messages`` instead.
123
-
124
- .. versionchanged:: 2.0.0
125
- Added `allow_none` parameter, which makes validation/deserialization of `None`
126
- consistent across fields.
127
-
128
- .. versionchanged:: 2.0.0
129
- Added `load_only` and `dump_only` parameters, which allow field skipping
130
- during the (de)serialization process.
131
-
132
- .. versionchanged:: 2.0.0
133
- Added `missing` parameter, which indicates the value for a field if the field
134
- is not found during deserialization.
135
-
136
- .. versionchanged:: 2.0.0
137
- ``default`` value is only used if explicitly set. Otherwise, missing values
138
- inputs are excluded from serialized output.
139
-
140
119
  .. versionchanged:: 3.0.0b8
141
120
  Add ``data_key`` parameter for the specifying the key in the input and
142
121
  output data. This parameter replaced both ``load_from`` and ``dump_to``.
122
+
123
+ .. versionchanged:: 3.13.0
124
+ Replace ``missing`` and ``default`` parameters with ``load_default`` and ``dump_default``.
143
125
  """
144
126
 
145
127
  # Some fields, such as Method fields and Function fields, are not expected
@@ -426,9 +408,6 @@ class Field(FieldABC):
426
408
  :raise ValidationError: In case of formatting or validation failure.
427
409
  :return: The deserialized value.
428
410
 
429
- .. versionchanged:: 2.0.0
430
- Added ``attr`` and ``data`` parameters.
431
-
432
411
  .. versionchanged:: 3.0.0
433
412
  Added ``**kwargs`` to signature.
434
413
  """
@@ -749,10 +728,6 @@ class List(Field):
749
728
  :param cls_or_instance: A field class or instance.
750
729
  :param kwargs: The same keyword arguments that :class:`Field` receives.
751
730
 
752
- .. versionchanged:: 2.0.0
753
- The ``allow_none`` parameter now applies to deserialization and
754
- has the same semantics as the other fields.
755
-
756
731
  .. versionchanged:: 3.0.0rc9
757
732
  Does not serialize scalar values to single-item lists.
758
733
  """
@@ -1464,9 +1439,6 @@ class TimeDelta(Field):
1464
1439
  will always be truncated to microseconds.
1465
1440
  For example, `1.12345` interpreted as microseconds will result in `timedelta(microseconds=1)`.
1466
1441
 
1467
- .. versionchanged:: 2.0.0
1468
- Always serializes to an integer value to avoid rounding errors.
1469
- Add `precision` parameter.
1470
1442
  .. versionchanged:: 3.17.0
1471
1443
  Allow (de)serialization to `float` through use of a new `serialization_type` parameter.
1472
1444
  `int` is the default to retain previous behaviour.
@@ -1949,9 +1921,6 @@ class Method(Field):
1949
1921
  a value The method must take a single argument ``value``, which is the
1950
1922
  value to deserialize.
1951
1923
 
1952
- .. versionchanged:: 2.0.0
1953
- Removed optional ``context`` parameter on methods. Use ``self.context`` instead.
1954
-
1955
1924
  .. versionchanged:: 2.3.0
1956
1925
  Deprecated ``method_name`` parameter in favor of ``serialize`` and allow
1957
1926
  ``serialize`` to not be passed at all.
@@ -2070,8 +2039,6 @@ class Constant(Field):
2070
2039
  ``dump_only=True`` or ``load_only=True`` respectively.
2071
2040
 
2072
2041
  :param constant: The constant to return for the field attribute.
2073
-
2074
- .. versionadded:: 2.0.0
2075
2042
  """
2076
2043
 
2077
2044
  _CHECK_ATTRIBUTE = False
@@ -280,13 +280,6 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
280
280
 
281
281
  .. versionchanged:: 3.0.0
282
282
  `prefix` parameter removed.
283
-
284
- .. versionchanged:: 2.0.0
285
- `__validators__`, `__preprocessors__`, and `__data_handlers__` are removed in favor of
286
- `marshmallow.decorators.validates_schema`,
287
- `marshmallow.decorators.pre_load` and `marshmallow.decorators.post_dump`.
288
- `__accessor__` and `__error_handler__` are deprecated. Implement the
289
- `handle_error` and `get_attribute` methods instead.
290
283
  """
291
284
 
292
285
  TYPE_MAPPING = {
@@ -422,7 +415,7 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
422
415
  @classmethod
423
416
  def from_dict(
424
417
  cls,
425
- fields: dict[str, ma_fields.Field | type[ma_fields.Field]],
418
+ fields: dict[str, ma_fields.Field],
426
419
  *,
427
420
  name: str = "GeneratedSchema",
428
421
  ) -> type[Schema]:
@@ -444,11 +437,10 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
444
437
 
445
438
  .. versionadded:: 3.0.0
446
439
  """
447
- attrs = fields.copy()
448
- attrs["Meta"] = type(
440
+ Meta = type(
449
441
  "GeneratedMeta", (getattr(cls, "Meta", object),), {"register": False}
450
442
  )
451
- schema_cls = type(name, (cls,), attrs)
443
+ schema_cls = type(name, (cls,), {**fields.copy(), "Meta": Meta})
452
444
  return schema_cls
453
445
 
454
446
  ##### Override-able methods #####
@@ -463,8 +455,6 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
463
455
  :param many: Value of ``many`` on dump or load.
464
456
  :param partial: Value of ``partial`` on load.
465
457
 
466
- .. versionadded:: 2.0.0
467
-
468
458
  .. versionchanged:: 3.0.0rc9
469
459
  Receives `many` and `partial` (on deserialization) as keyword arguments.
470
460
  """
@@ -473,8 +463,6 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
473
463
  def get_attribute(self, obj: typing.Any, attr: str, default: typing.Any):
474
464
  """Defines how to pull values from an object to serialize.
475
465
 
476
- .. versionadded:: 2.0.0
477
-
478
466
  .. versionchanged:: 3.0.0a1
479
467
  Changed position of ``obj`` and ``attr``.
480
468
  """
@@ -508,9 +496,6 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
508
496
  :param obj: The object(s) to serialize.
509
497
  :param bool many: `True` if ``data`` should be serialized as a collection.
510
498
  :return: A dictionary of the serialized data
511
-
512
- .. versionchanged:: 1.0.0
513
- Renamed from ``marshal``.
514
499
  """
515
500
  if many and obj is not None:
516
501
  return [self._serialize(d, many=False) for d in obj]
@@ -138,7 +138,7 @@ def get_fixed_timezone(offset: int | float | dt.timedelta) -> dt.timezone:
138
138
  if isinstance(offset, dt.timedelta):
139
139
  offset = offset.total_seconds() // 60
140
140
  sign = "-" if offset < 0 else "+"
141
- hhmm = "%02d%02d" % divmod(abs(offset), 60)
141
+ hhmm = "{:02d}{:02d}".format(*divmod(abs(offset), 60))
142
142
  name = sign + hhmm
143
143
  return dt.timezone(dt.timedelta(minutes=offset), name)
144
144
 
@@ -1,42 +0,0 @@
1
- #version-warning-banner {
2
- margin: 10px 0;
3
- padding: 10px;
4
- border-radius: 4px;
5
-
6
- letter-spacing: 1px;
7
- color: #fff;
8
- text-shadow: 0 0 2px #000;
9
- text-align: center;
10
- font-size: 0.9em;
11
-
12
- background: #004b6b
13
- repeating-linear-gradient(
14
- 135deg,
15
- transparent,
16
- transparent 20px,
17
- rgba(255, 255, 255, 0.1) 20px,
18
- rgba(255, 255, 255, 0.1) 40px
19
- );
20
- }
21
-
22
- #version-warning-banner .admonition-title {
23
- font-size: inherit;
24
- font-weight: bold;
25
- }
26
-
27
- #version-warning-banner p.admonition-title::after {
28
- content: none;
29
- }
30
-
31
- #version-warning-banner a {
32
- color: #fff;
33
- border-color: #fff;
34
- }
35
-
36
- #version-warning-banner p {
37
- display: inline;
38
- }
39
-
40
- div.warning {
41
- border: 0;
42
- }
@@ -1,9 +0,0 @@
1
- .. _api_fields:
2
-
3
- Fields
4
- ======
5
-
6
- .. automodule:: marshmallow.fields
7
- :members:
8
- :private-members:
9
- :autosummary:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes