marshmallow 4.1.0__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]
marshmallow/validate.py CHANGED
@@ -187,7 +187,7 @@ class URL(Validator):
187
187
  self.relative = relative
188
188
  self.absolute = absolute
189
189
  self.error: str = error or self.default_message
190
- self.schemes = schemes or self.default_schemes
190
+ self.schemes = {s.lower() for s in schemes} if schemes else self.default_schemes
191
191
  self.require_tld = require_tld
192
192
 
193
193
  def _repr_args(self) -> str:
@@ -623,8 +623,7 @@ class OneOf(Validator):
623
623
  :param valuegetter: Can be a callable or a string. In the former case, it must
624
624
  be a one-argument callable which returns the value of a
625
625
  choice. In the latter case, the string specifies the name
626
- of an attribute of the choice objects. Defaults to `str()`
627
- or `str()`.
626
+ of an attribute of the choice objects. Defaults to `str()`.
628
627
  """
629
628
  valuegetter = valuegetter if callable(valuegetter) else attrgetter(valuegetter)
630
629
  pairs = zip_longest(self.choices, self.labels, fillvalue="")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: marshmallow
3
- Version: 4.1.0
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
@@ -10,10 +10,10 @@ marshmallow/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  marshmallow/schema.py,sha256=tgcgL1wqJTMd6irpGL7x89lDUNP4cPRCNPY1y6-kBeI,49955
11
11
  marshmallow/types.py,sha256=X2DVsg8H7fFqco5yK2tZDwoqjxRPFjVurEdT-YogNC8,1161
12
12
  marshmallow/utils.py,sha256=YI38vVbIwa9T1kPrnW8sF6HmTbi0MFZYNzINKwtbxew,5334
13
- marshmallow/validate.py,sha256=X6uhUir-2DqUVzKMkEN6I8LrLPJ1mbL8RECRggByllU,23931
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.0.dist-info/licenses/LICENSE,sha256=kGtdkFHkJhRMsXOtkRZnuOvQWpxYTCwmwTWzKj7RIAE,1064
17
- marshmallow-4.1.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
18
- marshmallow-4.1.0.dist-info/METADATA,sha256=JQA9KW9qwD2NGhc3sAF4VSU3xIfjssg7LJn39lq8we0,7439
19
- marshmallow-4.1.0.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,,