marshmallow 3.20.2__tar.gz → 3.21.1__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 (91) hide show
  1. {marshmallow-3.20.2 → marshmallow-3.21.1}/CHANGELOG.rst +23 -0
  2. {marshmallow-3.20.2 → marshmallow-3.21.1}/LICENSE +1 -1
  3. {marshmallow-3.20.2/src/marshmallow.egg-info → marshmallow-3.21.1}/PKG-INFO +25 -35
  4. {marshmallow-3.20.2 → marshmallow-3.21.1}/README.rst +1 -6
  5. marshmallow-3.21.1/SECURITY.md +5 -0
  6. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/conf.py +4 -20
  7. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/upgrading.rst +1 -3
  8. marshmallow-3.21.1/pyproject.toml +90 -0
  9. marshmallow-3.21.1/src/marshmallow/__init__.py +81 -0
  10. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/base.py +1 -0
  11. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/class_registry.py +5 -4
  12. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/exceptions.py +0 -1
  13. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/fields.py +26 -28
  14. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/schema.py +19 -20
  15. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/utils.py +2 -5
  16. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/validate.py +5 -6
  17. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/base.py +3 -4
  18. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/conftest.py +1 -1
  19. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_deserialization.py +7 -9
  20. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_exceptions.py +1 -1
  21. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_fields.py +7 -10
  22. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_options.py +2 -3
  23. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_registry.py +1 -1
  24. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_schema.py +4 -2
  25. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_serialization.py +6 -6
  26. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_utils.py +3 -3
  27. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_validate.py +19 -6
  28. marshmallow-3.21.1/tests/test_version_attributes.py +15 -0
  29. marshmallow-3.21.1/tox.ini +35 -0
  30. marshmallow-3.20.2/AUTHORS.rst +0 -176
  31. marshmallow-3.20.2/MANIFEST.in +0 -13
  32. marshmallow-3.20.2/PKG-INFO +0 -210
  33. marshmallow-3.20.2/examples/flask_example.py +0 -140
  34. marshmallow-3.20.2/examples/inflection_example.py +0 -30
  35. marshmallow-3.20.2/examples/package_json_example.py +0 -50
  36. marshmallow-3.20.2/examples/peewee_example.py +0 -209
  37. marshmallow-3.20.2/examples/textblob_example.py +0 -32
  38. marshmallow-3.20.2/pyproject.toml +0 -3
  39. marshmallow-3.20.2/setup.cfg +0 -23
  40. marshmallow-3.20.2/setup.py +0 -92
  41. marshmallow-3.20.2/src/marshmallow/__init__.py +0 -42
  42. marshmallow-3.20.2/src/marshmallow.egg-info/SOURCES.txt +0 -85
  43. marshmallow-3.20.2/src/marshmallow.egg-info/dependency_links.txt +0 -1
  44. marshmallow-3.20.2/src/marshmallow.egg-info/not-zip-safe +0 -1
  45. marshmallow-3.20.2/src/marshmallow.egg-info/requires.txt +0 -23
  46. marshmallow-3.20.2/src/marshmallow.egg-info/top_level.txt +0 -1
  47. {marshmallow-3.20.2 → marshmallow-3.21.1}/CONTRIBUTING.rst +0 -0
  48. {marshmallow-3.20.2 → marshmallow-3.21.1}/NOTICE +0 -0
  49. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/.gitignore +0 -0
  50. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/_static/css/versionwarning.css +0 -0
  51. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/_static/marshmallow-logo.png +0 -0
  52. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/_templates/donate.html +0 -0
  53. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/_templates/useful-links.html +0 -0
  54. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/about.rst.inc +0 -0
  55. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/api_reference.rst +0 -0
  56. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/authors.rst +0 -0
  57. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/changelog.rst +0 -0
  58. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/code_of_conduct.rst +0 -0
  59. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/contributing.rst +0 -0
  60. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/custom_fields.rst +0 -0
  61. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/dashing.json +0 -0
  62. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/ecosystem.rst +0 -0
  63. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/examples.rst +0 -0
  64. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/extending.rst +0 -0
  65. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/index.rst +0 -0
  66. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/install.rst +0 -0
  67. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/kudos.rst +0 -0
  68. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/license.rst +0 -0
  69. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/marshmallow.class_registry.rst +0 -0
  70. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/marshmallow.decorators.rst +0 -0
  71. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/marshmallow.error_store.rst +0 -0
  72. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/marshmallow.exceptions.rst +0 -0
  73. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/marshmallow.fields.rst +0 -0
  74. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/marshmallow.schema.rst +0 -0
  75. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/marshmallow.utils.rst +0 -0
  76. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/marshmallow.validate.rst +0 -0
  77. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/nesting.rst +0 -0
  78. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/quickstart.rst +0 -0
  79. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/whos_using.rst +0 -0
  80. {marshmallow-3.20.2 → marshmallow-3.21.1}/docs/why.rst +0 -0
  81. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/decorators.py +0 -0
  82. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/error_store.py +0 -0
  83. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/orderedset.py +0 -0
  84. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/py.typed +0 -0
  85. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/types.py +0 -0
  86. {marshmallow-3.20.2 → marshmallow-3.21.1}/src/marshmallow/warnings.py +0 -0
  87. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/__init__.py +0 -0
  88. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/foo_serializer.py +0 -0
  89. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/mypy_test_cases/test_validation_error.py +0 -0
  90. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_decorators.py +6 -6
  91. {marshmallow-3.20.2 → marshmallow-3.21.1}/tests/test_error_store.py +0 -0
@@ -1,6 +1,29 @@
1
1
  Changelog
2
2
  ---------
3
3
 
4
+ 3.21.1 (2024-03-04)
5
+ *******************
6
+
7
+ Bug fixes:
8
+
9
+ - Fix error message when field is declared as a class and not an instance (:issue:`2245`).
10
+ Thanks :user:`travnick` for reporting.
11
+
12
+ 3.21.0 (2024-02-26)
13
+ *******************
14
+
15
+ Bug fixes:
16
+
17
+ - Fix validation of ``URL`` fields to allow missing user field,
18
+ per NWG RFC 3986 (:issue:`2232`). Thanks :user:`ddennerline3` for reporting
19
+ and :user:`deckar01` for the PR.
20
+
21
+ Other changes:
22
+
23
+ - *Backwards-incompatible*: ``__version__``, ``__parsed_version__``, and ``__version_info__``
24
+ attributes are deprecated (:issue:`2227`). Use feature detection or
25
+ ``importlib.metadata.version("marshmallow")`` instead.
26
+
4
27
  3.20.2 (2024-01-09)
5
28
  *******************
6
29
 
@@ -1,4 +1,4 @@
1
- Copyright 2024 Steven Loria and contributors
1
+ Copyright Steven Loria and contributors
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -1,16 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: marshmallow
3
- Version: 3.20.2
3
+ Version: 3.21.1
4
4
  Summary: A lightweight library for converting complex datatypes to and from native Python datatypes.
5
- Home-page: https://github.com/marshmallow-code/marshmallow
6
- Author: Steven Loria
7
- Author-email: sloria1@gmail.com
8
- License: MIT
9
- Project-URL: Changelog, https://marshmallow.readthedocs.io/en/latest/changelog.html
10
- Project-URL: Issues, https://github.com/marshmallow-code/marshmallow/issues
11
- Project-URL: Funding, https://opencollective.com/marshmallow
12
- Project-URL: Tidelift, https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi
13
- Keywords: serialization,rest,json,api,marshal,marshalling,deserialization,validation,schema
5
+ Author-email: Steven Loria <sloria1@gmail.com>
6
+ Maintainer-email: Steven Loria <sloria1@gmail.com>, Jérôme Lafréchoux <jerome@jolimont.fr>, Jared Deckard <jared@shademaps.com>
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/x-rst
14
9
  Classifier: Development Status :: 5 - Production/Stable
15
10
  Classifier: Intended Audience :: Developers
16
11
  Classifier: License :: OSI Approved :: MIT License
@@ -20,27 +15,26 @@ Classifier: Programming Language :: Python :: 3.9
20
15
  Classifier: Programming Language :: Python :: 3.10
21
16
  Classifier: Programming Language :: Python :: 3.11
22
17
  Classifier: Programming Language :: Python :: 3.12
23
- Requires-Python: >=3.8
24
- License-File: LICENSE
25
18
  Requires-Dist: packaging>=17.0
26
- Provides-Extra: tests
27
- Requires-Dist: pytest; extra == "tests"
28
- Requires-Dist: pytz; extra == "tests"
29
- Requires-Dist: simplejson; extra == "tests"
30
- Provides-Extra: lint
31
- Requires-Dist: pre-commit<4.0,>=2.4; extra == "lint"
32
- Provides-Extra: docs
33
- Requires-Dist: sphinx==7.2.6; extra == "docs"
34
- Requires-Dist: sphinx-issues==3.0.1; extra == "docs"
35
- Requires-Dist: alabaster==0.7.15; extra == "docs"
36
- Requires-Dist: sphinx-version-warning==1.1.2; extra == "docs"
37
- Requires-Dist: autodocsumm==0.2.12; extra == "docs"
19
+ Requires-Dist: marshmallow[tests] ; extra == "dev"
20
+ Requires-Dist: tox ; extra == "dev"
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"
24
+ Requires-Dist: alabaster==0.7.16 ; extra == "docs"
25
+ Requires-Dist: sphinx-version-warning==1.1.2 ; extra == "docs"
26
+ Requires-Dist: autodocsumm==0.2.12 ; extra == "docs"
27
+ Requires-Dist: pytest ; extra == "tests"
28
+ Requires-Dist: pytz ; extra == "tests"
29
+ Requires-Dist: simplejson ; extra == "tests"
30
+ Project-URL: Changelog, https://marshmallow.readthedocs.io/en/latest/changelog.html
31
+ Project-URL: Funding, https://opencollective.com/marshmallow
32
+ Project-URL: Issues, https://github.com/marshmallow-code/marshmallow/issues
33
+ Project-URL: Source, https://github.com/marshmallow-code/marshmallow
34
+ Project-URL: Tidelift, https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi
38
35
  Provides-Extra: dev
39
- Requires-Dist: pytest; extra == "dev"
40
- Requires-Dist: pytz; extra == "dev"
41
- Requires-Dist: simplejson; extra == "dev"
42
- Requires-Dist: pre-commit<4.0,>=2.4; extra == "dev"
43
- Requires-Dist: tox; extra == "dev"
36
+ Provides-Extra: docs
37
+ Provides-Extra: tests
44
38
 
45
39
  ********************************************
46
40
  marshmallow: simplified object serialization
@@ -61,11 +55,6 @@ marshmallow: simplified object serialization
61
55
  .. image:: https://readthedocs.org/projects/marshmallow/badge/
62
56
  :target: https://marshmallow.readthedocs.io/
63
57
  :alt: Documentation
64
-
65
- .. image:: https://badgen.net/badge/code%20style/black/000
66
- :target: https://github.com/ambv/black
67
- :alt: code style: black
68
-
69
58
 
70
59
  **marshmallow** is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes.
71
60
 
@@ -200,7 +189,7 @@ Project Links
200
189
  - Docs: https://marshmallow.readthedocs.io/
201
190
  - Changelog: https://marshmallow.readthedocs.io/en/latest/changelog.html
202
191
  - Contributing Guidelines: https://marshmallow.readthedocs.io/en/latest/contributing.html
203
- - PyPI: https://pypi.python.org/pypi/marshmallow
192
+ - PyPI: https://pypi.org/project/marshmallow/
204
193
  - Issues: https://github.com/marshmallow-code/marshmallow/issues
205
194
  - Donate: https://opencollective.com/marshmallow
206
195
 
@@ -208,3 +197,4 @@ License
208
197
  =======
209
198
 
210
199
  MIT licensed. See the bundled `LICENSE <https://github.com/marshmallow-code/marshmallow/blob/dev/LICENSE>`_ file for more details.
200
+
@@ -17,11 +17,6 @@ marshmallow: simplified object serialization
17
17
  .. image:: https://readthedocs.org/projects/marshmallow/badge/
18
18
  :target: https://marshmallow.readthedocs.io/
19
19
  :alt: Documentation
20
-
21
- .. image:: https://badgen.net/badge/code%20style/black/000
22
- :target: https://github.com/ambv/black
23
- :alt: code style: black
24
-
25
20
 
26
21
  **marshmallow** is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes.
27
22
 
@@ -156,7 +151,7 @@ Project Links
156
151
  - Docs: https://marshmallow.readthedocs.io/
157
152
  - Changelog: https://marshmallow.readthedocs.io/en/latest/changelog.html
158
153
  - Contributing Guidelines: https://marshmallow.readthedocs.io/en/latest/contributing.html
159
- - PyPI: https://pypi.python.org/pypi/marshmallow
154
+ - PyPI: https://pypi.org/project/marshmallow/
160
155
  - Issues: https://github.com/marshmallow-code/marshmallow/issues
161
156
  - Donate: https://opencollective.com/marshmallow
162
157
 
@@ -0,0 +1,5 @@
1
+ # Security Contact Information
2
+
3
+ To report a security vulnerability, please use the
4
+ [Tidelift security contact](https://tidelift.com/security).
5
+ Tidelift will coordinate the fix and disclosure.
@@ -1,13 +1,7 @@
1
- import sys
2
- import os
3
- import time
4
- import datetime as dt
1
+ import importlib.metadata
5
2
 
6
3
  import alabaster
7
4
 
8
- sys.path.insert(0, os.path.abspath(os.path.join("..", "src")))
9
- import marshmallow # noqa: E402
10
-
11
5
  extensions = [
12
6
  "sphinx.ext.autodoc",
13
7
  "sphinx.ext.intersphinx",
@@ -27,22 +21,13 @@ issues_github_path = "marshmallow-code/marshmallow"
27
21
 
28
22
  templates_path = ["_templates"]
29
23
 
30
- # Use SOURCE_DATE_EPOCH for reproducible build output https://reproducible-builds.org/docs/source-date-epoch/
31
- build_date = dt.datetime.utcfromtimestamp(
32
- int(os.environ.get("SOURCE_DATE_EPOCH", time.time()))
33
- )
34
-
35
24
  source_suffix = ".rst"
36
25
  master_doc = "index"
37
26
 
38
27
  project = "marshmallow"
39
- copyright = (
40
- ' {:%Y} <a href="https://stevenloria.com">Steven Loria</a> and contributors'.format(
41
- build_date
42
- )
43
- )
28
+ copyright = '<a href="https://stevenloria.com">Steven Loria</a> and contributors'
44
29
 
45
- version = release = marshmallow.__version__
30
+ version = release = importlib.metadata.version("marshmallow")
46
31
 
47
32
  exclude_patterns = ["_build"]
48
33
 
@@ -57,7 +42,6 @@ html_show_sourcelink = False
57
42
 
58
43
  html_theme_options = {
59
44
  "logo": "marshmallow-logo.png",
60
- "logo_name": None,
61
45
  "description": "Object serialization and deserialization, lightweight and fluffy.",
62
46
  "description_font_style": "italic",
63
47
  "github_user": "marshmallow-code",
@@ -74,7 +58,7 @@ html_theme_options = {
74
58
  "warn_border": "#EEE",
75
59
  # Used to populate the useful-links.html template
76
60
  "extra_nav_links": {
77
- "marshmallow @ PyPI": "https://pypi.python.org/pypi/marshmallow",
61
+ "marshmallow @ PyPI": "https://pypi.org/project/marshmallow/",
78
62
  "marshmallow @ GitHub": "https://github.com/marshmallow-code/marshmallow",
79
63
  "Issue Tracker": "https://github.com/marshmallow-code/marshmallow/issues",
80
64
  "Ecosystem": "https://github.com/marshmallow-code/marshmallow/wiki/Ecosystem",
@@ -62,9 +62,7 @@ Upgrading to 3.0
62
62
  Python compatibility
63
63
  ********************
64
64
 
65
- The marshmallow 3.x series supports Python >= 3.5.
66
-
67
- Python 2.6, 2.7, 3.3, and 3.4 are no longer supported.
65
+ The marshmallow 3.x series supports Python >= 3.8.
68
66
 
69
67
 
70
68
  Schemas are always strict
@@ -0,0 +1,90 @@
1
+ [project]
2
+ name = "marshmallow"
3
+ version = "3.21.1"
4
+ description = "A lightweight library for converting complex datatypes to and from native Python datatypes."
5
+ readme = "README.rst"
6
+ license = { file = "LICENSE" }
7
+ authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }]
8
+ maintainers = [
9
+ { name = "Steven Loria", email = "sloria1@gmail.com" },
10
+ { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" },
11
+ { name = "Jared Deckard", email = "jared@shademaps.com" },
12
+ ]
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ ]
24
+ requires-python = ">=3.8"
25
+ dependencies = ["packaging>=17.0"]
26
+
27
+ [project.urls]
28
+ Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html"
29
+ Funding = "https://opencollective.com/marshmallow"
30
+ Issues = "https://github.com/marshmallow-code/marshmallow/issues"
31
+ Source = "https://github.com/marshmallow-code/marshmallow"
32
+ Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi"
33
+
34
+ [project.optional-dependencies]
35
+ docs = [
36
+ "sphinx==7.2.6",
37
+ "sphinx-issues==4.0.0",
38
+ "alabaster==0.7.16",
39
+ "sphinx-version-warning==1.1.2",
40
+ "autodocsumm==0.2.12",
41
+ ]
42
+ tests = ["pytest", "pytz", "simplejson"]
43
+ dev = ["marshmallow[tests]", "tox", "pre-commit~=3.5"]
44
+
45
+ [build-system]
46
+ requires = ["flit_core<4"]
47
+ build-backend = "flit_core.buildapi"
48
+
49
+ [tool.flit.sdist]
50
+ include = [
51
+ "docs/",
52
+ "tests/",
53
+ "CHANGELOG.rst",
54
+ "CONTRIBUTING.rst",
55
+ "SECURITY.md",
56
+ "NOTICE",
57
+ "tox.ini",
58
+ ]
59
+ exclude = ["docs/_build/"]
60
+
61
+ [tool.ruff]
62
+ src = ["src"]
63
+ fix = true
64
+ show-fixes = true
65
+ show-source = true
66
+
67
+ [tool.ruff.lint]
68
+ ignore = ["E203", "E266", "E501", "E731"]
69
+ select = [
70
+ "B", # flake8-bugbear
71
+ "E", # pycodestyle error
72
+ "F", # pyflakes
73
+ "I", # isort
74
+ "UP", # pyupgrade
75
+ "W", # pycodestyle warning
76
+ ]
77
+
78
+ [tool.ruff.per-file-ignores]
79
+ "tests/*" = ["E721"]
80
+
81
+ [tool.mypy]
82
+ ignore_missing_imports = true
83
+ warn_unreachable = true
84
+ warn_unused_ignores = true
85
+ warn_redundant_casts = true
86
+ no_implicit_optional = true
87
+
88
+ [tool.pytest.ini_options]
89
+ norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases"
90
+ addopts = "-v --tb=short"
@@ -0,0 +1,81 @@
1
+ from __future__ import annotations
2
+
3
+ import importlib.metadata
4
+ import typing
5
+
6
+ from packaging.version import Version
7
+
8
+ from marshmallow.decorators import (
9
+ post_dump,
10
+ post_load,
11
+ pre_dump,
12
+ pre_load,
13
+ validates,
14
+ validates_schema,
15
+ )
16
+ from marshmallow.exceptions import ValidationError
17
+ from marshmallow.schema import Schema, SchemaOpts
18
+ from marshmallow.utils import EXCLUDE, INCLUDE, RAISE, missing, pprint
19
+
20
+ from . import fields
21
+
22
+
23
+ def __getattr__(name: str) -> typing.Any:
24
+ import warnings
25
+
26
+ if name == "__version__":
27
+ warnings.warn(
28
+ "The '__version__' attribute is deprecated and will be removed in"
29
+ " in a future version. Use feature detection or"
30
+ " 'importlib.metadata.version(\"marshmallow\")' instead.",
31
+ DeprecationWarning,
32
+ stacklevel=2,
33
+ )
34
+ return importlib.metadata.version("marshmallow")
35
+
36
+ if name == "__parsed_version__":
37
+ warnings.warn(
38
+ "The '__parsed_version__' attribute is deprecated and will be removed in"
39
+ " in a future version. Use feature detection or"
40
+ " 'packaging.Version(importlib.metadata.version(\"marshmallow\"))' instead.",
41
+ DeprecationWarning,
42
+ stacklevel=2,
43
+ )
44
+ return Version(importlib.metadata.version("marshmallow"))
45
+
46
+ if name == "__version_info__":
47
+ warnings.warn(
48
+ "The '__version_info__' attribute is deprecated and will be removed in"
49
+ " in a future version. Use feature detection or"
50
+ " 'packaging.Version(importlib.metadata.version(\"marshmallow\")).release' instead.",
51
+ DeprecationWarning,
52
+ stacklevel=2,
53
+ )
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]
58
+ if __parsed_version__.pre:
59
+ __version_info__ += __parsed_version__.pre # type: ignore[assignment]
60
+ return __version_info__
61
+
62
+ raise AttributeError(name)
63
+
64
+
65
+ __all__ = [
66
+ "EXCLUDE",
67
+ "INCLUDE",
68
+ "RAISE",
69
+ "Schema",
70
+ "SchemaOpts",
71
+ "fields",
72
+ "validates",
73
+ "validates_schema",
74
+ "pre_dump",
75
+ "post_dump",
76
+ "pre_load",
77
+ "post_load",
78
+ "pprint",
79
+ "ValidationError",
80
+ "missing",
81
+ ]
@@ -8,6 +8,7 @@ These are necessary to avoid circular imports between schema.py and fields.py.
8
8
  Users should not need to use this module directly.
9
9
  """
10
10
  from __future__ import annotations
11
+
11
12
  from abc import ABC, abstractmethod
12
13
 
13
14
 
@@ -10,6 +10,7 @@ class:`fields.Nested <marshmallow.fields.Nested>`.
10
10
  from __future__ import annotations
11
11
 
12
12
  import typing
13
+
13
14
  from marshmallow.exceptions import RegistryError
14
15
 
15
16
  if typing.TYPE_CHECKING:
@@ -76,16 +77,16 @@ def get_class(classname: str, all: bool = False) -> list[SchemaType] | SchemaTyp
76
77
  classes = _registry[classname]
77
78
  except KeyError as error:
78
79
  raise RegistryError(
79
- "Class with name {!r} was not found. You may need "
80
- "to import the class.".format(classname)
80
+ f"Class with name {classname!r} was not found. You may need "
81
+ "to import the class."
81
82
  ) from error
82
83
  if len(classes) > 1:
83
84
  if all:
84
85
  return _registry[classname]
85
86
  raise RegistryError(
86
- "Multiple classes with name {!r} "
87
+ f"Multiple classes with name {classname!r} "
87
88
  "were found. Please use the full, "
88
- "module-qualified path.".format(classname)
89
+ "module-qualified path."
89
90
  )
90
91
  else:
91
92
  return _registry[classname][0]
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
 
4
4
  import typing
5
5
 
6
-
7
6
  # Key used for schema-level validation errors
8
7
  SCHEMA = "_schema"
9
8
 
@@ -4,28 +4,30 @@ from __future__ import annotations
4
4
  import collections
5
5
  import copy
6
6
  import datetime as dt
7
- import numbers
8
- import uuid
9
- import ipaddress
10
7
  import decimal
8
+ import ipaddress
11
9
  import math
10
+ import numbers
12
11
  import typing
12
+ import uuid
13
13
  import warnings
14
- from enum import Enum as EnumType
15
14
  from collections.abc import Mapping as _Mapping
15
+ from enum import Enum as EnumType
16
16
 
17
- from marshmallow import validate, utils, class_registry, types
17
+ from marshmallow import class_registry, types, utils, validate
18
18
  from marshmallow.base import FieldABC, SchemaABC
19
+ from marshmallow.exceptions import (
20
+ FieldInstanceResolutionError,
21
+ StringNotCollectionError,
22
+ ValidationError,
23
+ )
19
24
  from marshmallow.utils import (
25
+ is_aware,
20
26
  is_collection,
21
- missing as missing_,
22
27
  resolve_field_instance,
23
- is_aware,
24
28
  )
25
- from marshmallow.exceptions import (
26
- ValidationError,
27
- StringNotCollectionError,
28
- FieldInstanceResolutionError,
29
+ from marshmallow.utils import (
30
+ missing as missing_,
29
31
  )
30
32
  from marshmallow.validate import And, Length
31
33
  from marshmallow.warnings import RemovedInMarshmallow4Warning
@@ -237,14 +239,12 @@ class Field(FieldABC):
237
239
 
238
240
  def __repr__(self) -> str:
239
241
  return (
240
- "<fields.{ClassName}(dump_default={self.dump_default!r}, "
241
- "attribute={self.attribute!r}, "
242
- "validate={self.validate}, required={self.required}, "
243
- "load_only={self.load_only}, dump_only={self.dump_only}, "
244
- "load_default={self.load_default}, allow_none={self.allow_none}, "
245
- "error_messages={self.error_messages})>".format(
246
- ClassName=self.__class__.__name__, self=self
247
- )
242
+ f"<fields.{self.__class__.__name__}(dump_default={self.dump_default!r}, "
243
+ f"attribute={self.attribute!r}, "
244
+ f"validate={self.validate}, required={self.required}, "
245
+ f"load_only={self.load_only}, dump_only={self.dump_only}, "
246
+ f"load_default={self.load_default}, allow_none={self.allow_none}, "
247
+ f"error_messages={self.error_messages})>"
248
248
  )
249
249
 
250
250
  def __deepcopy__(self, memo):
@@ -281,9 +281,9 @@ class Field(FieldABC):
281
281
  except KeyError as error:
282
282
  class_name = self.__class__.__name__
283
283
  message = (
284
- "ValidationError raised by `{class_name}`, but error key `{key}` does "
284
+ f"ValidationError raised by `{class_name}`, but error key `{key}` does "
285
285
  "not exist in the `error_messages` dictionary."
286
- ).format(class_name=class_name, key=key)
286
+ )
287
287
  raise AssertionError(message) from error
288
288
  if isinstance(msg, (str, bytes)):
289
289
  msg = msg.format(**kwargs)
@@ -297,9 +297,7 @@ class Field(FieldABC):
297
297
  Use `make_error <marshmallow.fields.Field.make_error>` instead.
298
298
  """
299
299
  warnings.warn(
300
- '`Field.fail` is deprecated. Use `raise self.make_error("{}", ...)` instead.'.format(
301
- key
302
- ),
300
+ f'`Field.fail` is deprecated. Use `raise self.make_error("{key}", ...)` instead.',
303
301
  RemovedInMarshmallow4Warning,
304
302
  stacklevel=2,
305
303
  )
@@ -611,7 +609,7 @@ class Nested(Field):
611
609
  elif not isinstance(nested, (str, bytes)):
612
610
  raise ValueError(
613
611
  "`Nested` fields must be passed a "
614
- "`Schema`, not {}.".format(nested.__class__)
612
+ f"`Schema`, not {nested.__class__}."
615
613
  )
616
614
  elif nested == "self":
617
615
  schema_class = self.root.__class__
@@ -1827,9 +1825,9 @@ class IPInterface(Field):
1827
1825
  return value.exploded
1828
1826
  return value.compressed
1829
1827
 
1830
- def _deserialize(
1831
- self, value, attr, data, **kwargs
1832
- ) -> None | (ipaddress.IPv4Interface | ipaddress.IPv6Interface):
1828
+ def _deserialize(self, value, attr, data, **kwargs) -> None | (
1829
+ ipaddress.IPv4Interface | ipaddress.IPv6Interface
1830
+ ):
1833
1831
  if value is None:
1834
1832
  return None
1835
1833
  try:
@@ -1,23 +1,21 @@
1
1
  """The :class:`Schema` class, including its metaclass and options (class Meta)."""
2
2
  from __future__ import annotations
3
- from abc import ABCMeta
4
3
 
5
- from collections import defaultdict, OrderedDict
6
- from collections.abc import Mapping
7
- from functools import lru_cache
4
+ import copy
8
5
  import datetime as dt
9
- import uuid
10
6
  import decimal
11
- import copy
12
7
  import inspect
13
8
  import json
14
9
  import typing
10
+ import uuid
15
11
  import warnings
12
+ from abc import ABCMeta
13
+ from collections import OrderedDict, defaultdict
14
+ from collections.abc import Mapping
15
+ from functools import lru_cache
16
16
 
17
- from marshmallow import base, fields as ma_fields, class_registry, types
18
- from marshmallow.error_store import ErrorStore
19
- from marshmallow.exceptions import ValidationError, StringNotCollectionError
20
- from marshmallow.orderedset import OrderedSet
17
+ from marshmallow import base, class_registry, types
18
+ from marshmallow import fields as ma_fields
21
19
  from marshmallow.decorators import (
22
20
  POST_DUMP,
23
21
  POST_LOAD,
@@ -26,15 +24,18 @@ from marshmallow.decorators import (
26
24
  VALIDATES,
27
25
  VALIDATES_SCHEMA,
28
26
  )
27
+ from marshmallow.error_store import ErrorStore
28
+ from marshmallow.exceptions import StringNotCollectionError, ValidationError
29
+ from marshmallow.orderedset import OrderedSet
29
30
  from marshmallow.utils import (
30
- RAISE,
31
31
  EXCLUDE,
32
32
  INCLUDE,
33
- missing,
34
- set_value,
33
+ RAISE,
35
34
  get_value,
36
35
  is_collection,
37
36
  is_instance_or_subclass,
37
+ missing,
38
+ set_value,
38
39
  validate_unknown_parameter_value,
39
40
  )
40
41
  from marshmallow.warnings import RemovedInMarshmallow4Warning
@@ -407,9 +408,7 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
407
408
  self.error_messages = messages
408
409
 
409
410
  def __repr__(self) -> str:
410
- return "<{ClassName}(many={self.many})>".format(
411
- ClassName=self.__class__.__name__, self=self
412
- )
411
+ return f"<{self.__class__.__name__}(many={self.many})>"
413
412
 
414
413
  @property
415
414
  def dict_class(self) -> type:
@@ -1004,7 +1003,7 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
1004
1003
  "The data_key argument for one or more fields collides "
1005
1004
  "with another field's name or data_key argument. "
1006
1005
  "Check the following field names and "
1007
- "data_key arguments: {}".format(list(data_keys_duplicates))
1006
+ f"data_key arguments: {list(data_keys_duplicates)}"
1008
1007
  )
1009
1008
  load_attributes = [obj.attribute or name for name, obj in load_fields.items()]
1010
1009
  if len(load_attributes) != len(set(load_attributes)):
@@ -1015,7 +1014,7 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
1015
1014
  "The attribute argument for one or more fields collides "
1016
1015
  "with another field's name or attribute argument. "
1017
1016
  "Check the following field names and "
1018
- "attribute arguments: {}".format(list(attributes_duplicates))
1017
+ f"attribute arguments: {list(attributes_duplicates)}"
1019
1018
  )
1020
1019
 
1021
1020
  self.fields = fields_dict
@@ -1048,9 +1047,9 @@ class Schema(base.SchemaABC, metaclass=SchemaMeta):
1048
1047
  # the type checker's perspective.
1049
1048
  if isinstance(field_obj, type) and issubclass(field_obj, base.FieldABC):
1050
1049
  msg = (
1051
- 'Field for "{field_name}" must be declared as a '
1050
+ f'Field for "{field_name}" must be declared as a '
1052
1051
  "Field instance, not a class. "
1053
- 'Did you mean "fields.{field_obj.__name__}()"?'
1052
+ f'Did you mean "fields.{field_obj.__name__}()"?' # type: ignore
1054
1053
  )
1055
1054
  raise TypeError(msg) from error
1056
1055
  raise error
@@ -2,8 +2,8 @@
2
2
  from __future__ import annotations
3
3
 
4
4
  import collections
5
- import functools
6
5
  import datetime as dt
6
+ import functools
7
7
  import inspect
8
8
  import json
9
9
  import re
@@ -311,10 +311,7 @@ def set_value(dct: dict[str, typing.Any], key: str, value: typing.Any):
311
311
  target = dct.setdefault(head, {})
312
312
  if not isinstance(target, dict):
313
313
  raise ValueError(
314
- "Cannot set {key} in {head} "
315
- "due to existing value: {target}".format(
316
- key=key, head=head, target=target
317
- )
314
+ f"Cannot set {key} in {head} " f"due to existing value: {target}"
318
315
  )
319
316
  set_value(target, rest, value)
320
317
  else: