marshmallow 3.21.1__tar.gz → 3.21.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 (74) hide show
  1. {marshmallow-3.21.1 → marshmallow-3.21.3}/CHANGELOG.rst +16 -0
  2. {marshmallow-3.21.1 → marshmallow-3.21.3}/PKG-INFO +3 -7
  3. {marshmallow-3.21.1 → marshmallow-3.21.3}/README.rst +0 -4
  4. {marshmallow-3.21.1 → marshmallow-3.21.3}/pyproject.toml +8 -5
  5. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/__init__.py +3 -3
  6. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/base.py +1 -0
  7. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/class_registry.py +3 -1
  8. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/decorators.py +17 -10
  9. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/exceptions.py +1 -0
  10. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/fields.py +11 -9
  11. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/schema.py +1 -2
  12. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/types.py +1 -0
  13. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/utils.py +3 -0
  14. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/validate.py +7 -9
  15. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/base.py +1 -0
  16. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/conftest.py +1 -0
  17. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_deserialization.py +5 -2
  18. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_schema.py +1 -1
  19. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_serialization.py +5 -4
  20. {marshmallow-3.21.1 → marshmallow-3.21.3}/CONTRIBUTING.rst +0 -0
  21. {marshmallow-3.21.1 → marshmallow-3.21.3}/LICENSE +0 -0
  22. {marshmallow-3.21.1 → marshmallow-3.21.3}/NOTICE +0 -0
  23. {marshmallow-3.21.1 → marshmallow-3.21.3}/SECURITY.md +0 -0
  24. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/.gitignore +0 -0
  25. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/_static/css/versionwarning.css +0 -0
  26. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/_static/marshmallow-logo.png +0 -0
  27. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/_templates/donate.html +0 -0
  28. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/_templates/useful-links.html +0 -0
  29. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/about.rst.inc +0 -0
  30. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/api_reference.rst +0 -0
  31. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/authors.rst +0 -0
  32. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/changelog.rst +0 -0
  33. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/code_of_conduct.rst +0 -0
  34. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/conf.py +0 -0
  35. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/contributing.rst +0 -0
  36. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/custom_fields.rst +0 -0
  37. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/dashing.json +0 -0
  38. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/ecosystem.rst +0 -0
  39. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/examples.rst +0 -0
  40. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/extending.rst +0 -0
  41. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/index.rst +0 -0
  42. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/install.rst +0 -0
  43. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/kudos.rst +0 -0
  44. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/license.rst +0 -0
  45. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/marshmallow.class_registry.rst +0 -0
  46. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/marshmallow.decorators.rst +0 -0
  47. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/marshmallow.error_store.rst +0 -0
  48. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/marshmallow.exceptions.rst +0 -0
  49. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/marshmallow.fields.rst +0 -0
  50. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/marshmallow.schema.rst +0 -0
  51. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/marshmallow.utils.rst +0 -0
  52. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/marshmallow.validate.rst +0 -0
  53. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/nesting.rst +0 -0
  54. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/quickstart.rst +0 -0
  55. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/upgrading.rst +0 -0
  56. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/whos_using.rst +0 -0
  57. {marshmallow-3.21.1 → marshmallow-3.21.3}/docs/why.rst +0 -0
  58. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/error_store.py +0 -0
  59. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/orderedset.py +0 -0
  60. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/py.typed +0 -0
  61. {marshmallow-3.21.1 → marshmallow-3.21.3}/src/marshmallow/warnings.py +0 -0
  62. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/__init__.py +0 -0
  63. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/foo_serializer.py +0 -0
  64. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/mypy_test_cases/test_validation_error.py +0 -0
  65. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_decorators.py +0 -0
  66. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_error_store.py +0 -0
  67. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_exceptions.py +0 -0
  68. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_fields.py +0 -0
  69. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_options.py +0 -0
  70. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_registry.py +0 -0
  71. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_utils.py +0 -0
  72. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_validate.py +0 -0
  73. {marshmallow-3.21.1 → marshmallow-3.21.3}/tests/test_version_attributes.py +0 -0
  74. {marshmallow-3.21.1 → marshmallow-3.21.3}/tox.ini +0 -0
@@ -1,6 +1,22 @@
1
1
  Changelog
2
2
  ---------
3
3
 
4
+ 3.21.3 (2024-06-05)
5
+ *******************
6
+
7
+ Bug fixes:
8
+
9
+ - Fix memory leak that prevented schema instances from getting GC'd (:pr:`2277`).
10
+ Thanks :user:`mrcljx` for the PR.
11
+
12
+ 3.21.2 (2024-05-01)
13
+ *******************
14
+
15
+ Bug fixes:
16
+
17
+ - Allow timestamp 0 in ``fields.DateTime`` (:issue:`2133`).
18
+ Thanks :user:`flydzen` for reporting.
19
+
4
20
  3.21.1 (2024-03-04)
5
21
  *******************
6
22
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: marshmallow
3
- Version: 3.21.1
3
+ Version: 3.21.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>
@@ -19,8 +19,8 @@ Requires-Dist: packaging>=17.0
19
19
  Requires-Dist: marshmallow[tests] ; extra == "dev"
20
20
  Requires-Dist: tox ; extra == "dev"
21
21
  Requires-Dist: pre-commit~=3.5 ; extra == "dev"
22
- Requires-Dist: sphinx==7.2.6 ; extra == "docs"
23
- Requires-Dist: sphinx-issues==4.0.0 ; extra == "docs"
22
+ Requires-Dist: sphinx==7.3.7 ; extra == "docs"
23
+ Requires-Dist: sphinx-issues==4.1.0 ; extra == "docs"
24
24
  Requires-Dist: alabaster==0.7.16 ; extra == "docs"
25
25
  Requires-Dist: sphinx-version-warning==1.1.2 ; extra == "docs"
26
26
  Requires-Dist: autodocsumm==0.2.12 ; extra == "docs"
@@ -157,10 +157,6 @@ Your logo will show up here with a link to your website. [`Become a sponsor`_]
157
157
 
158
158
  .. _`Become a sponsor`: https://opencollective.com/marshmallow#sponsor
159
159
 
160
- .. image:: https://opencollective.com/marshmallow/sponsor/0/avatar.svg
161
- :target: https://opencollective.com/marshmallow/sponsor/0/website
162
- :alt: Sponsors
163
-
164
160
  .. image:: https://opencollective.com/static/images/become_sponsor.svg
165
161
  :target: https://opencollective.com/marshmallow#sponsor
166
162
  :alt: Become a sponsor
@@ -119,10 +119,6 @@ Your logo will show up here with a link to your website. [`Become a sponsor`_]
119
119
 
120
120
  .. _`Become a sponsor`: https://opencollective.com/marshmallow#sponsor
121
121
 
122
- .. image:: https://opencollective.com/marshmallow/sponsor/0/avatar.svg
123
- :target: https://opencollective.com/marshmallow/sponsor/0/website
124
- :alt: Sponsors
125
-
126
122
  .. image:: https://opencollective.com/static/images/become_sponsor.svg
127
123
  :target: https://opencollective.com/marshmallow#sponsor
128
124
  :alt: Become a sponsor
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "marshmallow"
3
- version = "3.21.1"
3
+ version = "3.21.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" }
@@ -33,8 +33,8 @@ Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=py
33
33
 
34
34
  [project.optional-dependencies]
35
35
  docs = [
36
- "sphinx==7.2.6",
37
- "sphinx-issues==4.0.0",
36
+ "sphinx==7.3.7",
37
+ "sphinx-issues==4.1.0",
38
38
  "alabaster==0.7.16",
39
39
  "sphinx-version-warning==1.1.2",
40
40
  "autodocsumm==0.2.12",
@@ -62,7 +62,10 @@ exclude = ["docs/_build/"]
62
62
  src = ["src"]
63
63
  fix = true
64
64
  show-fixes = true
65
- show-source = true
65
+ output-format = "full"
66
+
67
+ [tool.ruff.format]
68
+ docstring-code-format = true
66
69
 
67
70
  [tool.ruff.lint]
68
71
  ignore = ["E203", "E266", "E501", "E731"]
@@ -75,7 +78,7 @@ select = [
75
78
  "W", # pycodestyle warning
76
79
  ]
77
80
 
78
- [tool.ruff.per-file-ignores]
81
+ [tool.ruff.lint.per-file-ignores]
79
82
  "tests/*" = ["E721"]
80
83
 
81
84
  [tool.mypy]
@@ -52,9 +52,9 @@ def __getattr__(name: str) -> typing.Any:
52
52
  stacklevel=2,
53
53
  )
54
54
  __parsed_version__ = Version(importlib.metadata.version("marshmallow"))
55
- __version_info__: tuple[int, int, int] | tuple[
56
- int, int, int, str, int
57
- ] = __parsed_version__.release # type: ignore[assignment]
55
+ __version_info__: tuple[int, int, int] | tuple[int, int, int, str, int] = (
56
+ __parsed_version__.release # type: ignore[assignment]
57
+ )
58
58
  if __parsed_version__.pre:
59
59
  __version_info__ += __parsed_version__.pre # type: ignore[assignment]
60
60
  return __version_info__
@@ -7,6 +7,7 @@ These are necessary to avoid circular imports between schema.py and fields.py.
7
7
  This module is treated as private API.
8
8
  Users should not need to use this module directly.
9
9
  """
10
+
10
11
  from __future__ import annotations
11
12
 
12
13
  from abc import ABC, abstractmethod
@@ -7,6 +7,7 @@ class:`fields.Nested <marshmallow.fields.Nested>`.
7
7
  This module is treated as private API.
8
8
  Users should not need to use this module directly.
9
9
  """
10
+
10
11
  from __future__ import annotations
11
12
 
12
13
  import typing
@@ -35,7 +36,8 @@ def register(classname: str, cls: SchemaType) -> None:
35
36
  class MyClass:
36
37
  pass
37
38
 
38
- register('MyClass', MyClass)
39
+
40
+ register("MyClass", MyClass)
39
41
  # Registry:
40
42
  # {
41
43
  # 'MyClass': [path.to.MyClass],
@@ -15,39 +15,45 @@ signature.
15
15
  Example: ::
16
16
 
17
17
  from marshmallow import (
18
- Schema, pre_load, pre_dump, post_load, validates_schema,
19
- validates, fields, ValidationError
18
+ Schema,
19
+ pre_load,
20
+ pre_dump,
21
+ post_load,
22
+ validates_schema,
23
+ validates,
24
+ fields,
25
+ ValidationError,
20
26
  )
21
27
 
22
- class UserSchema(Schema):
23
28
 
29
+ class UserSchema(Schema):
24
30
  email = fields.Str(required=True)
25
31
  age = fields.Integer(required=True)
26
32
 
27
33
  @post_load
28
34
  def lowerstrip_email(self, item, many, **kwargs):
29
- item['email'] = item['email'].lower().strip()
35
+ item["email"] = item["email"].lower().strip()
30
36
  return item
31
37
 
32
38
  @pre_load(pass_many=True)
33
39
  def remove_envelope(self, data, many, **kwargs):
34
- namespace = 'results' if many else 'result'
40
+ namespace = "results" if many else "result"
35
41
  return data[namespace]
36
42
 
37
43
  @post_dump(pass_many=True)
38
44
  def add_envelope(self, data, many, **kwargs):
39
- namespace = 'results' if many else 'result'
45
+ namespace = "results" if many else "result"
40
46
  return {namespace: data}
41
47
 
42
48
  @validates_schema
43
49
  def validate_email(self, data, **kwargs):
44
- if len(data['email']) < 3:
45
- raise ValidationError('Email must be more than 3 characters', 'email')
50
+ if len(data["email"]) < 3:
51
+ raise ValidationError("Email must be more than 3 characters", "email")
46
52
 
47
- @validates('age')
53
+ @validates("age")
48
54
  def validate_age(self, data, **kwargs):
49
55
  if data < 14:
50
- raise ValidationError('Too young!')
56
+ raise ValidationError("Too young!")
51
57
 
52
58
  .. note::
53
59
  These decorators only work with instance methods. Class and static
@@ -58,6 +64,7 @@ Example: ::
58
64
  If you need to guarantee order of different processing steps, you should put
59
65
  them in the same processing method.
60
66
  """
67
+
61
68
  from __future__ import annotations
62
69
 
63
70
  import functools
@@ -1,4 +1,5 @@
1
1
  """Exception classes for marshmallow-related errors."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import typing
@@ -1,4 +1,5 @@
1
1
  """Field classes for various types of data."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import collections
@@ -393,7 +394,7 @@ class Field(FieldABC):
393
394
  class TitleCase(Field):
394
395
  def _serialize(self, value, attr, obj, **kwargs):
395
396
  if not value:
396
- return ''
397
+ return ""
397
398
  return str(value).title()
398
399
 
399
400
  :param value: The value to be serialized.
@@ -495,6 +496,7 @@ class Nested(Field):
495
496
  parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True)
496
497
  siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name"))))
497
498
 
499
+
498
500
  class ParentSchema(Schema):
499
501
  id = fields.Str()
500
502
  children = fields.List(
@@ -511,10 +513,10 @@ class Nested(Field):
511
513
  ::
512
514
 
513
515
  # Yes
514
- author = fields.Nested(UserSchema, only=('id', 'name'))
516
+ author = fields.Nested(UserSchema, only=("id", "name"))
515
517
 
516
518
  # No
517
- author = fields.Nested(UserSchema(), only=('id', 'name'))
519
+ author = fields.Nested(UserSchema(), only=("id", "name"))
518
520
 
519
521
  :param nested: `Schema` instance, class, class name (string), dictionary, or callable that
520
522
  returns a `Schema` or dictionary. Dictionaries are converted with `Schema.from_dict`.
@@ -626,7 +628,7 @@ class Nested(Field):
626
628
  return self._schema
627
629
 
628
630
  def _nested_normalized_option(self, option_name: str) -> list[str]:
629
- nested_field = "%s." % self.name
631
+ nested_field = f"{self.name}."
630
632
  return [
631
633
  field.split(nested_field, 1)[1]
632
634
  for field in getattr(self.root, option_name, set())
@@ -676,16 +678,18 @@ class Pluck(Nested):
676
678
 
677
679
  from marshmallow import Schema, fields
678
680
 
681
+
679
682
  class ArtistSchema(Schema):
680
683
  id = fields.Int()
681
684
  name = fields.Str()
682
685
 
686
+
683
687
  class AlbumSchema(Schema):
684
- artist = fields.Pluck(ArtistSchema, 'id')
688
+ artist = fields.Pluck(ArtistSchema, "id")
685
689
 
686
690
 
687
- in_data = {'artist': 42}
688
- loaded = AlbumSchema().load(in_data) # => {'artist': {'id': 42}}
691
+ in_data = {"artist": 42}
692
+ loaded = AlbumSchema().load(in_data) # => {'artist': {'id': 42}}
689
693
  dumped = AlbumSchema().dump(loaded) # => {'artist': 42}
690
694
 
691
695
  :param Schema nested: The Schema class or class name (string)
@@ -1281,8 +1285,6 @@ class DateTime(Field):
1281
1285
  return value.strftime(data_format)
1282
1286
 
1283
1287
  def _deserialize(self, value, attr, data, **kwargs) -> dt.datetime:
1284
- if not value: # Falsy values, e.g. '', None, [] are not valid
1285
- raise self.make_error("invalid", input=value, obj_type=self.OBJ_TYPE)
1286
1288
  data_format = self.format or self.DEFAULT_FORMAT
1287
1289
  func = self.DESERIALIZATION_FUNCS.get(data_format)
1288
1290
  try:
@@ -1,4 +1,5 @@
1
1
  """The :class:`Schema` class, including its metaclass and options (class Meta)."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import copy
@@ -12,7 +13,6 @@ import warnings
12
13
  from abc import ABCMeta
13
14
  from collections import OrderedDict, defaultdict
14
15
  from collections.abc import Mapping
15
- from functools import lru_cache
16
16
 
17
17
  from marshmallow import base, class_registry, types
18
18
  from marshmallow import fields as ma_fields
@@ -1055,7 +1055,6 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
1055
1055
  raise error
1056
1056
  self.on_bind_field(field_name, field_obj)
1057
1057
 
1058
- @lru_cache(maxsize=8) # noqa (https://github.com/PyCQA/flake8-bugbear/issues/310)
1059
1058
  def _has_processors(self, tag) -> bool:
1060
1059
  return bool(self._hooks[(tag, True)] or self._hooks[(tag, False)])
1061
1060
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  This module is provisional. Types may be modified, added, and removed between minor releases.
6
6
  """
7
+
7
8
  import typing
8
9
 
9
10
  StrSequenceOrSet = typing.Union[typing.Sequence[str], typing.AbstractSet[str]]
@@ -1,4 +1,5 @@
1
1
  """Utility methods for marshmallow."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import collections
@@ -191,6 +192,8 @@ def from_iso_date(value):
191
192
 
192
193
 
193
194
  def from_timestamp(value: typing.Any) -> dt.datetime:
195
+ if value is True or value is False:
196
+ raise ValueError("Not a valid POSIX timestamp")
194
197
  value = float(value)
195
198
  if value < 0:
196
199
  raise ValueError("Not a valid POSIX timestamp")
@@ -1,4 +1,5 @@
1
1
  """Validation classes for various types of data."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import re
@@ -36,8 +37,7 @@ class Validator(ABC):
36
37
  return ""
37
38
 
38
39
  @abstractmethod
39
- def __call__(self, value: typing.Any) -> typing.Any:
40
- ...
40
+ def __call__(self, value: typing.Any) -> typing.Any: ...
41
41
 
42
42
 
43
43
  class And(Validator):
@@ -47,10 +47,12 @@ class And(Validator):
47
47
 
48
48
  from marshmallow import validate, ValidationError
49
49
 
50
+
50
51
  def is_even(value):
51
52
  if value % 2 != 0:
52
53
  raise ValidationError("Not an even value.")
53
54
 
55
+
54
56
  validator = validate.And(validate.Range(min=0), is_even)
55
57
  validator(-1)
56
58
  # ValidationError: ['Must be greater than or equal to 0.', 'Not an even value.']
@@ -334,9 +336,7 @@ class Range(Validator):
334
336
  )
335
337
 
336
338
  def _repr_args(self) -> str:
337
- return "min={!r}, max={!r}, min_inclusive={!r}, max_inclusive={!r}".format(
338
- self.min, self.max, self.min_inclusive, self.max_inclusive
339
- )
339
+ return f"min={self.min!r}, max={self.max!r}, min_inclusive={self.min_inclusive!r}, max_inclusive={self.max_inclusive!r}"
340
340
 
341
341
  def _format_error(self, value: _T, message: str) -> str:
342
342
  return (self.error or message).format(input=value, min=self.min, max=self.max)
@@ -486,12 +486,10 @@ class Regexp(Validator):
486
486
  return self.error.format(input=value, regex=self.regex.pattern)
487
487
 
488
488
  @typing.overload
489
- def __call__(self, value: str) -> str:
490
- ...
489
+ def __call__(self, value: str) -> str: ...
491
490
 
492
491
  @typing.overload
493
- def __call__(self, value: bytes) -> bytes:
494
- ...
492
+ def __call__(self, value: bytes) -> bytes: ...
495
493
 
496
494
  def __call__(self, value):
497
495
  if self.regex.match(value) is None:
@@ -1,4 +1,5 @@
1
1
  """Test utilities and fixtures."""
2
+
2
3
  import datetime as dt
3
4
  import functools
4
5
  import uuid
@@ -1,4 +1,5 @@
1
1
  """Pytest fixtures that are available in all test modules."""
2
+
2
3
  import pytest
3
4
 
4
5
  from tests.base import Blog, User, UserSchema
@@ -422,6 +422,9 @@ class TestFieldDeserialization:
422
422
  [
423
423
  "not-a-datetime",
424
424
  42,
425
+ True,
426
+ False,
427
+ 0,
425
428
  "",
426
429
  [],
427
430
  "2018",
@@ -576,7 +579,7 @@ class TestFieldDeserialization:
576
579
  @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"])
577
580
  @pytest.mark.parametrize(
578
581
  "in_value",
579
- ["", "!@#", 0, -1, dt.datetime(2013, 11, 10, 1, 23, 45)],
582
+ ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)],
580
583
  )
581
584
  def test_invalid_timestamp_field_deserialization(self, fmt, in_value):
582
585
  field = fields.DateTime(format=fmt)
@@ -1288,7 +1291,7 @@ class TestFieldDeserialization:
1288
1291
  assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec"
1289
1292
 
1290
1293
  def test_datetime_list_field_deserialization(self):
1291
- dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.utcnow()
1294
+ dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc)
1292
1295
  dstrings = [each.isoformat() for each in dtimes]
1293
1296
  field = fields.List(fields.DateTime())
1294
1297
  result = field.deserialize(dstrings)
@@ -85,7 +85,7 @@ def test_load_validation_error_stores_input_data_and_valid_data():
85
85
 
86
86
  schema = MySchema()
87
87
  input_data = {
88
- "always_valid": dt.datetime.utcnow().isoformat(),
88
+ "always_valid": dt.datetime.now(dt.timezone.utc).isoformat(),
89
89
  "always_invalid": 24,
90
90
  }
91
91
  try:
@@ -1,4 +1,5 @@
1
1
  """Tests for field serialization."""
2
+
2
3
  import datetime as dt
3
4
  import decimal
4
5
  import ipaddress
@@ -826,7 +827,7 @@ class TestFieldSerialization:
826
827
  fields.TimeDelta(fields.TimeDelta.SECONDS, str)
827
828
 
828
829
  def test_datetime_list_field(self):
829
- obj = DateTimeList([dt.datetime.utcnow(), dt.datetime.now()])
830
+ obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()])
830
831
  field = fields.List(fields.DateTime)
831
832
  result = field.serialize("dtimes", obj)
832
833
  assert all(type(each) is str for each in result)
@@ -838,7 +839,7 @@ class TestFieldSerialization:
838
839
 
839
840
  def test_list_field_work_with_generator_single_value(self):
840
841
  def custom_generator():
841
- yield dt.datetime.utcnow()
842
+ yield dt.datetime.now(dt.timezone.utc)
842
843
 
843
844
  obj = DateTimeList(custom_generator())
844
845
  field = fields.List(fields.DateTime)
@@ -847,7 +848,7 @@ class TestFieldSerialization:
847
848
 
848
849
  def test_list_field_work_with_generators_multiple_values(self):
849
850
  def custom_generator():
850
- yield from [dt.datetime.utcnow(), dt.datetime.now()]
851
+ yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()]
851
852
 
852
853
  obj = DateTimeList(custom_generator())
853
854
  field = fields.List(fields.DateTime)
@@ -909,7 +910,7 @@ class TestFieldSerialization:
909
910
  fields.List(ASchema)
910
911
 
911
912
  def test_datetime_integer_tuple_field(self):
912
- obj = DateTimeIntegerTuple((dt.datetime.utcnow(), 42))
913
+ obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42))
913
914
  field = fields.Tuple([fields.DateTime, fields.Integer])
914
915
  result = field.serialize("dtime_int", obj)
915
916
  assert type(result[0]) is str
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes