marshmallow 4.1.1__py3-none-any.whl → 4.1.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]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: marshmallow
3
- Version: 4.1.1
3
+ Version: 4.1.2
4
4
  Summary: A lightweight library for converting complex datatypes to and from native Python datatypes.
5
5
  Author-email: Steven Loria <oss@stevenloria.com>
6
6
  Maintainer-email: Steven Loria <oss@stevenloria.com>, Jérôme Lafréchoux <jerome@jolimont.fr>, Jared Deckard <jared@shademaps.com>
@@ -2,7 +2,7 @@ marshmallow/__init__.py,sha256=9XHBRTrPmbVaU-Z8CWo8nlcf9Z5VvkRD37d1luJuAaM,573
2
2
  marshmallow/class_registry.py,sha256=HTC9srCEaRsiy5L_vUKQso7IQfeZeRXxZfz4_2NitoM,3029
3
3
  marshmallow/constants.py,sha256=v86zJ9nywyN7euiHQw8hJSkuPyeuflUvv0jZVtfre8M,415
4
4
  marshmallow/decorators.py,sha256=maOozW03vQ7k9qZqZ_TvTYR3w--kb0NfkAOy1Q0TnZ0,10165
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=1L3ZHwQNelWU5ujIPsON5tZ6WQPk64pBGWNyfwhz608,2273
7
7
  marshmallow/fields.py,sha256=DxFiqatexaj9tbs395Pre_Sr2h3BdlF2scSKxcJLV1M,72154
8
8
  marshmallow/orderedset.py,sha256=adVCG4HtfYFexqZThiFsiwc_i0g8LNWI_bF6cjMz2r0,2953
@@ -13,7 +13,7 @@ marshmallow/utils.py,sha256=YI38vVbIwa9T1kPrnW8sF6HmTbi0MFZYNzINKwtbxew,5334
13
13
  marshmallow/validate.py,sha256=HUIjC6XOLRpu7PeoL0xEFnvOh9NzZQYQYb-j6XVL8y4,23942
14
14
  marshmallow/experimental/__init__.py,sha256=5_iaUmT7_f6QML2LJXmA3xqgk5UBAgCeIazHtC1GVgc,147
15
15
  marshmallow/experimental/context.py,sha256=_4KF6sNK6pE0MckyYTGXmU3hJL2tY-TN4oVmE_eDob0,2040
16
- marshmallow-4.1.1.dist-info/licenses/LICENSE,sha256=kGtdkFHkJhRMsXOtkRZnuOvQWpxYTCwmwTWzKj7RIAE,1064
17
- marshmallow-4.1.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
18
- marshmallow-4.1.1.dist-info/METADATA,sha256=eEQKSULNUI_5lj5IadDRCKURNT1reYzIqCaM7btBUK8,7439
19
- marshmallow-4.1.1.dist-info/RECORD,,
16
+ marshmallow-4.1.2.dist-info/licenses/LICENSE,sha256=kGtdkFHkJhRMsXOtkRZnuOvQWpxYTCwmwTWzKj7RIAE,1064
17
+ marshmallow-4.1.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
18
+ marshmallow-4.1.2.dist-info/METADATA,sha256=_eP5zTxYMv8DlSvhtc90lXtXwISKtwlAd8slaG2DZb0,7439
19
+ marshmallow-4.1.2.dist-info/RECORD,,