Skip to content

Commit

Permalink
Support Python 3.13 and marshmallow 4.0 (#209)
Browse files Browse the repository at this point in the history
* Update build matrix

* Update badge

* Update black in pre-commit

* Update changelog

* Update annotations

* Update mypy config to match marshmallow
  • Loading branch information
sloria authored Jan 7, 2025
1 parent bb636e4 commit f2bc89f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
fail-fast: false
matrix:
include:
- { name: "3.8", python: "3.8", tox: py38 }
- { name: "3.12", python: "3.12", tox: py312 }
- { name: "3.9", python: "3.9", tox: py39-marshmallow3 }
- { name: "3.13", python: "3.13", tox: py313-marshmallow3 }
- { name: "lowest", python: "3.9", tox: py39-lowest }
- { name: "dev", python: "3.13", tox: py313-marshmallowdev }
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
Expand All @@ -34,7 +36,7 @@ jobs:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: "3.11"
python-version: "3.13"
- run: python -m pip install --upgrade pip
- run: python -m pip install tox
- run: python -m tox -e lint
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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.14.1
hooks:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
---------

3.2.0 (unreleased)
******************

Support:

- Support Python 3.9-3.13.
- Support marshmallow 3-4.

3.1.1 (2024-02-13)
++++++++++++++++++

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ marshmallow-oneofschema
:target: https://github.com/marshmallow-code/flask-marshmallow/actions/workflows/build-release.yml
:alt: Build status

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

An extension to marshmallow to support schema (de)multiplexing.

Expand Down
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = ["marshmallow>=3.0.0,<4.0.0"]

[project.urls]
Expand Down Expand Up @@ -53,3 +53,10 @@ select = [
"UP", # pyupgrade
"W", # pycodestyle warning
]

[tool.mypy]
ignore_missing_imports = true
warn_unreachable = true
warn_unused_ignores = true
warn_redundant_casts = true
no_implicit_optional = true
4 changes: 3 additions & 1 deletion src/marshmallow_oneofschema/one_of_schema.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import typing

from marshmallow import Schema, ValidationError
Expand Down Expand Up @@ -59,7 +61,7 @@ def get_obj_type(self, obj):

type_field = "type"
type_field_remove = True
type_schemas: typing.Mapping[str, typing.Union[typing.Type[Schema], Schema]] = {}
type_schemas: typing.Mapping[str, type[Schema] | Schema] = {}

def get_obj_type(self, obj):
"""Returns name of the schema during dump() calls, given the object
Expand Down
10 changes: 8 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
[tox]
envlist=
lint
py{38,39,310,311,312}
py{39,310,311,312,313}-marshmallow3
py313-marshmallowdev
py39-lowest

[testenv]
extras = tests
deps =
marshmallow3: marshmallow>=3.0.0,<4.0.0
marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz
lowest: marshmallow==3.0.0
commands = pytest {posargs}

[testenv:lint]
deps = pre-commit~=3.5
deps = pre-commit~=4.0.1
skip_install = true
commands = pre-commit run --all-files

Expand Down

0 comments on commit f2bc89f

Please sign in to comment.