Skip to content

Commit f7e2b5b

Browse files
committed
Require marshmallow 4.0
1 parent 4308d12 commit f7e2b5b

5 files changed

Lines changed: 6 additions & 59 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
include:
16-
- { name: "3.10", python: "3.10", tox: py310-marshmallow3 }
17-
- { name: "3.14", python: "3.14", tox: py314-marshmallow3 }
18-
- { name: "3.10", python: "3.10", tox: py310-marshmallow4 }
19-
- { name: "3.14", python: "3.14", tox: py314-marshmallow4 }
16+
- { name: "3.10", python: "3.10", tox: py310-marshmallow }
17+
- { name: "3.14", python: "3.14", tox: py314-marshmallow }
2018
- { name: "lowest", python: "3.10", tox: py310-lowest }
2119
- { name: "dev", python: "3.14", tox: py314-marshmallowdev }
2220
steps:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ keywords = [
4242
]
4343
requires-python = ">=3.10"
4444
dependencies = [
45-
"marshmallow>=3.13.0,<5.0.0",
45+
"marshmallow>=4.0.0,<5.0.0",
4646
"packaging>=17.0",
4747
# depend on typing-extensions conditionally for annotations
4848
'typing_extensions>=4.0; python_version<"3.10"',

src/webargs/fields.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Field classes.
22
3-
Includes all fields from `marshmallow.fields` in addition to a custom
4-
`Nested` field and `DelimitedList`.
3+
Includes all fields from `marshmallow.fields` in addition to `DelimitedList`.
54
65
All fields can optionally take a special `location` keyword argument, which
76
tells webargs where to parse the request argument from.
@@ -26,30 +25,6 @@
2625
__all__ = ["DelimitedList", "DelimitedTuple"] + ma.fields.__all__
2726

2827

29-
# TODO: remove custom `Nested` in the next major release
30-
#
31-
# the `Nested` class is only needed on versions of marshmallow prior to v3.15.0
32-
# in that version, `ma.fields.Nested` gained the ability to consume dict inputs
33-
# prior to that, this subclass adds this capability
34-
#
35-
# if we drop support for ma.__version_info__ < (3, 15) we can do this
36-
class Nested(ma.fields.Nested): # type: ignore[no-redef]
37-
"""Same as `marshmallow.fields.Nested`, except can be passed a dictionary
38-
as the first argument, which will be converted to a `marshmallow.Schema`.
39-
40-
.. note::
41-
42-
The schema class here will always be `marshmallow.Schema`, regardless
43-
of whether a custom schema class is set on the parser. Pass an explicit schema
44-
class if necessary.
45-
"""
46-
47-
def __init__(self, nested, *args, **kwargs):
48-
if isinstance(nested, dict):
49-
nested = ma.Schema.from_dict(nested)
50-
super().__init__(nested, *args, **kwargs)
51-
52-
5328
class DelimitedFieldMixin:
5429
"""
5530
This is a mixin class for subclasses of ma.fields.List and ma.fields.Tuple

tests/test_core.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import collections
22
import datetime
3-
import importlib.metadata
43
import typing
54
from unittest import mock
65

@@ -16,15 +15,12 @@
1615
pre_load,
1716
validates_schema,
1817
)
19-
from packaging.version import Version
2018
from werkzeug.datastructures import MultiDict as WerkMultiDict
2119

2220
from webargs import ValidationError, fields
2321
from webargs.core import Parser, get_mimetype, is_json
2422
from webargs.multidictproxy import MultiDictProxy
2523

26-
MARSHMALLOW_VERSION = Version(importlib.metadata.version("marshmallow"))
27-
2824

2925
class MockHTTPError(Exception):
3026
def __init__(self, status_code, headers):
@@ -557,27 +553,6 @@ def test_required_with_custom_error(parser, web_request):
557553
assert "We need foo" in excinfo.value.messages["json"]["foo"]
558554

559555

560-
@pytest.mark.filterwarnings("ignore:Returning `False` from a validator is deprecated")
561-
@pytest.mark.skipif(
562-
MARSHMALLOW_VERSION.major >= 4,
563-
reason="marshmallow 4+ does not support validators returning False",
564-
)
565-
def test_required_with_custom_error_and_validation_error(parser, web_request):
566-
web_request.json = {"foo": ""}
567-
args = {
568-
"foo": fields.Str(
569-
required="We need foo",
570-
validate=lambda s: len(s) > 1,
571-
error_messages={"validator_failed": "foo required length is 3"},
572-
)
573-
}
574-
with pytest.raises(ValidationError) as excinfo:
575-
# Test that `validate` receives dictionary of args
576-
parser.parse(args, web_request)
577-
578-
assert "foo required length is 3" in excinfo.value.args[0]["foo"]
579-
580-
581556
def test_full_input_validator_receives_nonascii_input(web_request):
582557
def validate(val):
583558
return False

tox.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
[tox]
22
envlist=
33
lint
4-
py{310,311,312,313,314}-marshmallow{3,4}
4+
py{310,311,312,313,314}-marshmallow
55
py314-marshmallowdev
66
py310-lowest
77
docs
88

99
[testenv]
1010
extras = tests
1111
deps =
12-
marshmallow3: marshmallow>=3.0.0,<4.0.0
13-
marshmallow4: marshmallow>=4.0.0,<5.0.0
12+
marshmallow: marshmallow>=4.0.0,<5.0.0
1413
marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz
1514
lowest: flask==3.1.0
1615
lowest: Django==5.2.0

0 commit comments

Comments
 (0)