diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 3f601a0c..a9c25780 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -10,29 +10,14 @@ on: jobs: tests: name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - - { - name: "3.9-ma3", - python: "3.9", - os: ubuntu-latest, - tox: py39-marshmallow3, - } - - { - name: "3.13-ma3", - python: "3.13", - os: ubuntu-latest, - tox: py313-marshmallow3, - } - - { - name: "3.13-madev", - python: "3.13", - os: ubuntu-latest, - tox: py313-marshmallowdev, - } + - { name: "3.9-ma3", python: "3.9", tox: py39-marshmallow3 } + - { name: "3.13-ma3", python: "3.13", tox: py313-marshmallow3 } + - { name: "3.13-madev", python: "3.13", tox: py313-marshmallowdev } steps: - uses: actions/checkout@v4.2.2 - uses: actions/setup-python@v5 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e3c1fde9..bce3d753 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ ci: autoupdate_schedule: monthly repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.1 + rev: v0.8.6 hooks: - id: ruff - id: ruff-format @@ -15,9 +15,9 @@ repos: rev: 1.19.1 hooks: - id: blacken-docs - additional_dependencies: [black==23.12.1] + additional_dependencies: [black==24.10.0] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.13.0 + rev: v1.14.1 hooks: - id: mypy - additional_dependencies: ["marshmallow>=3,<4", "types-PyYAML"] + additional_dependencies: ["marshmallow>=3.24.1,<5", "types-PyYAML"] diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 26df76fe..60c8bb1e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ Changelog --------- +6.9.0 (unreleased) +****************** + +Support: + +- Support marshmallow 4 (:pr:`963`). + 6.8.0 (2024-12-02) ****************** diff --git a/README.rst b/README.rst index 64f964f2..d472589f 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ apispec ******* -|pypi| |build-status| |docs| |marshmallow3| |openapi| +|pypi| |build-status| |docs| |marshmallow-support| |openapi| .. |pypi| image:: https://badgen.net/pypi/v/apispec :target: https://pypi.org/project/apispec/ @@ -16,9 +16,9 @@ apispec :target: https://apispec.readthedocs.io/ :alt: Documentation -.. |marshmallow3| image:: https://badgen.net/badge/marshmallow/3?list=1 +.. |marshmallow-support| image:: https://badgen.net/badge/marshmallow/3,4?list=1 :target: https://marshmallow.readthedocs.io/en/latest/upgrading.html - :alt: marshmallow 3 only + :alt: marshmallow 3|4 compatible .. |openapi| image:: https://badgen.net/badge/OAS/2,3?list=1&color=cyan :target: https://github.com/OAI/OpenAPI-Specification diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py index 834ad193..e5373771 100644 --- a/src/apispec/ext/marshmallow/common.py +++ b/src/apispec/ext/marshmallow/common.py @@ -26,7 +26,7 @@ def resolve_schema_instance( return schema() if isinstance(schema, marshmallow.Schema): return schema - return marshmallow.class_registry.get_class(schema)() # type: ignore + return marshmallow.class_registry.get_class(schema)() def resolve_schema_cls( diff --git a/tests/test_ext_marshmallow_field.py b/tests/test_ext_marshmallow_field.py index 36d864c4..ab5cd625 100644 --- a/tests/test_ext_marshmallow_field.py +++ b/tests/test_ext_marshmallow_field.py @@ -19,7 +19,6 @@ def test_field2choices_preserving_order(openapi): ("FieldClass", "jsontype"), [ (fields.Integer, "integer"), - (fields.Number, "number"), (fields.Float, "number"), (fields.String, "string"), (fields.Str, "string"), @@ -46,9 +45,8 @@ def test_field2property_type(FieldClass, jsontype, spec_fixture): assert res["type"] == jsontype -@pytest.mark.parametrize("FieldClass", [fields.Field, fields.Raw]) -def test_field2property_no_type_(FieldClass, spec_fixture): - field = FieldClass() +def test_field2property_no_type(spec_fixture): + field = fields.Raw() res = spec_fixture.openapi.field2property(field) assert "type" not in res @@ -291,14 +289,14 @@ def test_field_with_load_only(spec_fixture): def test_field_with_range_no_type(spec_fixture): - field = fields.Field(validate=validate.Range(min=1, max=10)) + field = fields.Raw(validate=validate.Range(min=1, max=10)) res = spec_fixture.openapi.field2property(field) assert res["x-minimum"] == 1 assert res["x-maximum"] == 10 assert "type" not in res -@pytest.mark.parametrize("field", (fields.Number, fields.Integer)) +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) def test_field_with_range_string_type(spec_fixture, field): field = field(validate=validate.Range(min=1, max=10)) res = spec_fixture.openapi.field2property(field) diff --git a/tox.ini b/tox.ini index 0c5481d3..9beedcb0 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ envlist= lint py{39,310,311,312,313}-marshmallow3 - py312-marshmallowdev + py313-marshmallowdev docs [testenv]