Skip to content

Commit 59751b7

Browse files
authored
Update tests for marshmallow 4 compat; build updates (#963)
* Fix tests for marshmallow 4.0 * pre-commit autoupdate * Update changelog and badge * Fix badge * Update changelog * Remove unnecessary ignore; use fixed marshmallow version
1 parent 6583194 commit 59751b7

File tree

7 files changed

+24
-34
lines changed

7 files changed

+24
-34
lines changed

.github/workflows/build-release.yml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,14 @@ on:
1010
jobs:
1111
tests:
1212
name: ${{ matrix.name }}
13-
runs-on: ${{ matrix.os }}
13+
runs-on: ubuntu-latest
1414
strategy:
1515
fail-fast: false
1616
matrix:
1717
include:
18-
- {
19-
name: "3.9-ma3",
20-
python: "3.9",
21-
os: ubuntu-latest,
22-
tox: py39-marshmallow3,
23-
}
24-
- {
25-
name: "3.13-ma3",
26-
python: "3.13",
27-
os: ubuntu-latest,
28-
tox: py313-marshmallow3,
29-
}
30-
- {
31-
name: "3.13-madev",
32-
python: "3.13",
33-
os: ubuntu-latest,
34-
tox: py313-marshmallowdev,
35-
}
18+
- { name: "3.9-ma3", python: "3.9", tox: py39-marshmallow3 }
19+
- { name: "3.13-ma3", python: "3.13", tox: py313-marshmallow3 }
20+
- { name: "3.13-madev", python: "3.13", tox: py313-marshmallowdev }
3621
steps:
3722
- uses: actions/checkout@v4.2.2
3823
- uses: actions/setup-python@v5

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ci:
22
autoupdate_schedule: monthly
33
repos:
44
- repo: https://github.com/astral-sh/ruff-pre-commit
5-
rev: v0.8.1
5+
rev: v0.8.6
66
hooks:
77
- id: ruff
88
- id: ruff-format
@@ -15,9 +15,9 @@ repos:
1515
rev: 1.19.1
1616
hooks:
1717
- id: blacken-docs
18-
additional_dependencies: [black==23.12.1]
18+
additional_dependencies: [black==24.10.0]
1919
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v1.13.0
20+
rev: v1.14.1
2121
hooks:
2222
- id: mypy
23-
additional_dependencies: ["marshmallow>=3,<4", "types-PyYAML"]
23+
additional_dependencies: ["marshmallow>=3.24.1,<5", "types-PyYAML"]

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
---------
33

4+
6.9.0 (unreleased)
5+
******************
6+
7+
Support:
8+
9+
- Support marshmallow 4 (:pr:`963`).
10+
411
6.8.0 (2024-12-02)
512
******************
613

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apispec
33
*******
44

5-
|pypi| |build-status| |docs| |marshmallow3| |openapi|
5+
|pypi| |build-status| |docs| |marshmallow-support| |openapi|
66

77
.. |pypi| image:: https://badgen.net/pypi/v/apispec
88
:target: https://pypi.org/project/apispec/
@@ -16,9 +16,9 @@ apispec
1616
:target: https://apispec.readthedocs.io/
1717
:alt: Documentation
1818

19-
.. |marshmallow3| image:: https://badgen.net/badge/marshmallow/3?list=1
19+
.. |marshmallow-support| image:: https://badgen.net/badge/marshmallow/3,4?list=1
2020
:target: https://marshmallow.readthedocs.io/en/latest/upgrading.html
21-
:alt: marshmallow 3 only
21+
:alt: marshmallow 3|4 compatible
2222

2323
.. |openapi| image:: https://badgen.net/badge/OAS/2,3?list=1&color=cyan
2424
:target: https://github.com/OAI/OpenAPI-Specification

src/apispec/ext/marshmallow/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def resolve_schema_instance(
2626
return schema()
2727
if isinstance(schema, marshmallow.Schema):
2828
return schema
29-
return marshmallow.class_registry.get_class(schema)() # type: ignore
29+
return marshmallow.class_registry.get_class(schema)()
3030

3131

3232
def resolve_schema_cls(

tests/test_ext_marshmallow_field.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def test_field2choices_preserving_order(openapi):
1919
("FieldClass", "jsontype"),
2020
[
2121
(fields.Integer, "integer"),
22-
(fields.Number, "number"),
2322
(fields.Float, "number"),
2423
(fields.String, "string"),
2524
(fields.Str, "string"),
@@ -46,9 +45,8 @@ def test_field2property_type(FieldClass, jsontype, spec_fixture):
4645
assert res["type"] == jsontype
4746

4847

49-
@pytest.mark.parametrize("FieldClass", [fields.Field, fields.Raw])
50-
def test_field2property_no_type_(FieldClass, spec_fixture):
51-
field = FieldClass()
48+
def test_field2property_no_type(spec_fixture):
49+
field = fields.Raw()
5250
res = spec_fixture.openapi.field2property(field)
5351
assert "type" not in res
5452

@@ -291,14 +289,14 @@ def test_field_with_load_only(spec_fixture):
291289

292290

293291
def test_field_with_range_no_type(spec_fixture):
294-
field = fields.Field(validate=validate.Range(min=1, max=10))
292+
field = fields.Raw(validate=validate.Range(min=1, max=10))
295293
res = spec_fixture.openapi.field2property(field)
296294
assert res["x-minimum"] == 1
297295
assert res["x-maximum"] == 10
298296
assert "type" not in res
299297

300298

301-
@pytest.mark.parametrize("field", (fields.Number, fields.Integer))
299+
@pytest.mark.parametrize("field", (fields.Float, fields.Integer))
302300
def test_field_with_range_string_type(spec_fixture, field):
303301
field = field(validate=validate.Range(min=1, max=10))
304302
res = spec_fixture.openapi.field2property(field)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
envlist=
33
lint
44
py{39,310,311,312,313}-marshmallow3
5-
py312-marshmallowdev
5+
py313-marshmallowdev
66
docs
77

88
[testenv]

0 commit comments

Comments
 (0)