marshmallow 3.26.1__py3-none-any.whl → 3.26.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@ class ErrorStore:
18
18
  # field error -> store/merge error messages under field name key
19
19
  # schema error -> if string or list, store/merge under _schema key
20
20
  # -> if dict, store/merge with other top-level keys
21
+ messages = copy_containers(messages)
21
22
  if field_name != SCHEMA or not isinstance(messages, dict):
22
23
  messages = {field_name: messages}
23
24
  if index is not None:
@@ -25,6 +26,14 @@ class ErrorStore:
25
26
  self.errors = merge_errors(self.errors, messages)
26
27
 
27
28
 
29
+ def copy_containers(errors):
30
+ if isinstance(errors, list):
31
+ return [copy_containers(val) for val in errors]
32
+ if isinstance(errors, dict):
33
+ return {key: copy_containers(val) for key, val in errors.items()}
34
+ return errors
35
+
36
+
28
37
  def merge_errors(errors1, errors2): # noqa: PLR0911
29
38
  """Deeply merge two error messages.
30
39
 
@@ -37,24 +46,26 @@ def merge_errors(errors1, errors2): # noqa: PLR0911
37
46
  return errors1
38
47
  if isinstance(errors1, list):
39
48
  if isinstance(errors2, list):
40
- return errors1 + errors2
49
+ errors1.extend(errors2)
50
+ return errors1
41
51
  if isinstance(errors2, dict):
42
- return dict(errors2, **{SCHEMA: merge_errors(errors1, errors2.get(SCHEMA))})
43
- return [*errors1, errors2]
52
+ errors2[SCHEMA] = merge_errors(errors1, errors2.get(SCHEMA))
53
+ return errors2
54
+ errors1.append(errors2)
55
+ return errors1
44
56
  if isinstance(errors1, dict):
45
- if isinstance(errors2, list):
46
- return dict(errors1, **{SCHEMA: merge_errors(errors1.get(SCHEMA), errors2)})
47
57
  if isinstance(errors2, dict):
48
- errors = dict(errors1)
49
58
  for key, val in errors2.items():
50
- if key in errors:
51
- errors[key] = merge_errors(errors[key], val)
59
+ if key in errors1:
60
+ errors1[key] = merge_errors(errors1[key], val)
52
61
  else:
53
- errors[key] = val
54
- return errors
55
- return dict(errors1, **{SCHEMA: merge_errors(errors1.get(SCHEMA), errors2)})
62
+ errors1[key] = val
63
+ return errors1
64
+ errors1[SCHEMA] = merge_errors(errors1.get(SCHEMA), errors2)
65
+ return errors1
56
66
  if isinstance(errors2, list):
57
67
  return [errors1, *errors2]
58
68
  if isinstance(errors2, dict):
59
- return dict(errors2, **{SCHEMA: merge_errors(errors1, errors2.get(SCHEMA))})
69
+ errors2[SCHEMA] = merge_errors(errors1, errors2.get(SCHEMA))
70
+ return errors2
60
71
  return [errors1, errors2]
marshmallow/schema.py CHANGED
@@ -374,7 +374,7 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
374
374
 
375
375
  class MySchema2(Schema):
376
376
  # Type checkers will check attributes
377
- class Meta(Schema.Opts):
377
+ class Meta(Schema.Meta):
378
378
  additional = True # Incompatible types in assignment
379
379
 
380
380
  .. versionremoved:: 3.0.0b7 Remove ``strict``.
@@ -1139,7 +1139,7 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
1139
1139
  msg = (
1140
1140
  f'Field for "{field_name}" must be declared as a '
1141
1141
  "Field instance, not a class. "
1142
- f'Did you mean "fields.{field_obj.__name__}()"?' # type: ignore[attr-defined]
1142
+ f'Did you mean "fields.{field_obj.__name__}()"?'
1143
1143
  )
1144
1144
  raise TypeError(msg) from error
1145
1145
  raise
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: marshmallow
3
- Version: 3.26.1
3
+ Version: 3.26.2
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>
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Classifier: Programming Language :: Python :: 3.13
18
+ License-File: LICENSE
18
19
  Requires-Dist: packaging>=17.0
19
20
  Requires-Dist: marshmallow[tests] ; extra == "dev"
20
21
  Requires-Dist: tox ; extra == "dev"
@@ -2,17 +2,17 @@ marshmallow/__init__.py,sha256=TU1arjtOLs87YDfW4Z35YVbaY2CUXK-VgylcuL8LaQg,2387
2
2
  marshmallow/base.py,sha256=39W78-rnuzzx5T95YWBEECzjtqxdUA8XzYJNHd39VLg,1362
3
3
  marshmallow/class_registry.py,sha256=HTC9srCEaRsiy5L_vUKQso7IQfeZeRXxZfz4_2NitoM,3029
4
4
  marshmallow/decorators.py,sha256=pMjGPaXBZCRfAdQS3Bz5ieTZGA3BOv61FdTPsLwCtMQ,8749
5
- marshmallow/error_store.py,sha256=iCPSdw8nJGiS4fjWuIAY1aSI_Hhckcdo3l_g-7pjaMw,2240
5
+ marshmallow/error_store.py,sha256=5-62el8Ey2w59x8FDhUC5afPu63NXjumKiAagAGL9bY,2444
6
6
  marshmallow/exceptions.py,sha256=DuARdOcirCdJxmlp16V97hQKAXOokvdW12jXtYOlGyk,2326
7
7
  marshmallow/fields.py,sha256=TKVxFY9hLpq7ch6_HEb1be5uPw0fgs-uC4n5o_fTkg8,74756
8
8
  marshmallow/orderedset.py,sha256=-Lq83AWIIFs2bxptDwkHtfQ63ebX3WD3R6N3B5rRnVI,2936
9
9
  marshmallow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- marshmallow/schema.py,sha256=Dc6ent2eI-0g9phGc1FB4EURpSNDRGFOjpyE2BWwYTc,52207
10
+ marshmallow/schema.py,sha256=I5_eEaaJPs6pCP3Hk7UmA6LpIY_AGq5b8mQN9e-XD_c,52177
11
11
  marshmallow/types.py,sha256=VY0_D-Xou7nKjcvWB1iccm8cZtxI3rkis1nhNelNn5Q,979
12
12
  marshmallow/utils.py,sha256=tLzu9FDL3Ph51qKsoqWIyPSwg8dZ8rzjeXXGLUndHFE,11943
13
13
  marshmallow/validate.py,sha256=Fx3F8F20dBGg-Wrv84Chx5SYedX9E0l592hR4MxS0kQ,24652
14
14
  marshmallow/warnings.py,sha256=YHC0kQQBbTKCiA1FuwnbnXqrph7oKuU9BjTV4cxwnzE,192
15
- marshmallow-3.26.1.dist-info/LICENSE,sha256=kGtdkFHkJhRMsXOtkRZnuOvQWpxYTCwmwTWzKj7RIAE,1064
16
- marshmallow-3.26.1.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
17
- marshmallow-3.26.1.dist-info/METADATA,sha256=9TJTS8CSQ5yUx_cNqkUz_0dQU9p0gCQcsJ_lUeq_7tE,7310
18
- marshmallow-3.26.1.dist-info/RECORD,,
15
+ marshmallow-3.26.2.dist-info/licenses/LICENSE,sha256=kGtdkFHkJhRMsXOtkRZnuOvQWpxYTCwmwTWzKj7RIAE,1064
16
+ marshmallow-3.26.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
17
+ marshmallow-3.26.2.dist-info/METADATA,sha256=4EzTZh8SGuZS7Y-CJ4kCER__GppWvipXWz59tT_Waxs,7332
18
+ marshmallow-3.26.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: flit 3.10.1
2
+ Generator: flit 3.12.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any