Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
version: 2
updates:
- package-ecosystem: pip
- package-ecosystem: uv
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
interval: monthly
groups:
all-dependencies:
patterns: ["*"]
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
all-actions:
patterns: ["*"]
42 changes: 18 additions & 24 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,29 @@ jobs:
fail-fast: false
matrix:
include:
- { 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 }
- { name: "mypy-ma3", python: "3.13", tox: mypy-marshmallow3 }
- { name: "mypy-madev", python: "3.13", tox: mypy-marshmallowdev }
- { name: "3.10", tox: py310-marshmallow3 }
- { name: "3.14", tox: py314-marshmallow3 }
- { name: "lowest", tox: py310-lowest }
- { name: "dev", tox: py314-marshmallowdev }
- { name: "mypy-ma3", tox: mypy-marshmallow3 }
- { name: "mypy-madev", tox: mypy-marshmallowdev }
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python }}
- run: python -m pip install tox
- run: python -m tox -e${{ matrix.tox }}
enable-cache: true
- run: uv run tox -e${{ matrix.tox }}
build:
name: Build package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.13"
- name: Install pypa/build
run: python -m pip install build
- name: Build a binary wheel and a source tarball
run: python -m build
- name: Install twine
run: python -m pip install twine
- name: Check build
run: python -m twine check --strict dist/*
python-version: "3.14"
enable-cache: true
- run: uv build
- run: uvx twine check --strict dist/*
- name: Store the distribution packages
uses: actions/upload-artifact@v7
with:
Expand All @@ -53,11 +47,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.13"
- run: python -m pip install tox
- run: python -m tox -e lint
python-version: "3.14"
enable-cache: true
- run: uv run tox -e lint
publish-to-pypi:
name: PyPI release
if: startsWith(github.ref, 'refs/tags/')
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ nosetests.xml
.project
.pydevproject

# Virtualenvs
.venv

# Complexity
output/*.html
output/*/index.html
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ repos:
hooks:
- id: blacken-docs
additional_dependencies: [black==25.1.0]
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.10.9
hooks:
- id: uv-lock
18 changes: 11 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# https://docs.readthedocs.com/platform/stable/build-customization.html#install-dependencies-with-uv
version: 2
sphinx:
configuration: docs/conf.py
formats:
- pdf
build:
os: ubuntu-22.04
os: ubuntu-24.04
tools:
python: "3.13"
python:
install:
- method: pip
path: .
extra_requirements:
- docs
jobs:
pre_create_environment:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
create_environment:
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
install:
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
---------

unreleased
++++++++++

Other changes:

* Drop support for Python 3.9, which is EOL. Support Python 3.10-3.14.

1.4.2 (2025-04-09)
++++++++++++++++++

Expand Down
22 changes: 10 additions & 12 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@ Setting up for local development
$ git clone https://github.com/marshmallow-code/marshmallow-sqlalchemy.git
$ cd marshmallow-sqlalchemy

2. Install development requirements. **It is highly recommended that you use a virtualenv.**
Use the following command to install an editable version of
marshmallow-sqlalchemy along with its development requirements.
2. Install `uv <https://docs.astral.sh/uv/getting-started/installation/>`_.

3. Install development requirements.

.. code-block:: shell-session

# After activating your virtualenv
$ pip install -e '.[dev]'
$ uv sync

3. Install the pre-commit hooks, which will format and lint your git staged files.
4. (Optional but recommended) Install the pre-commit hooks, which will format and lint your git staged files.

.. code-block:: shell-session

# The pre-commit CLI was installed above
$ pre-commit install
$ uv run pre-commit install --allow-missing-config

Pull requests
--------------
Expand Down Expand Up @@ -70,19 +68,19 @@ To run all tests:

.. code-block:: shell-session

$ pytest
$ uv run pytest

To run formatting and syntax checks:

.. code-block:: shell-session

$ tox -e lint
$ uv run tox -e lint

(Optional) To run tests in all supported Python versions in their own virtual environments (must have each interpreter installed):

.. code-block:: shell-session

$ tox
$ uv run tox

Documentation
-------------
Expand All @@ -93,7 +91,7 @@ To build and serve the docs in "watch" mode:

.. code-block:: shell-session

$ tox -e docs-serve
$ uv run tox -e docs-serve

Changes to documentation will automatically trigger a rebuild.

Expand Down
31 changes: 19 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"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",
"Programming Language :: Python :: 3.14",
]
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"marshmallow>=3.18.0",
"SQLAlchemy>=1.4.40,<3.0",
"typing-extensions; python_version < '3.10'",
]

[project.urls]
Expand All @@ -28,17 +27,25 @@ Funding = "https://opencollective.com/marshmallow"
Issues = "https://github.com/marshmallow-code/marshmallow-sqlalchemy/issues"
Source = "https://github.com/marshmallow-code/marshmallow-sqlalchemy"

[project.optional-dependencies]
[dependency-groups]
docs = [
"furo==2025.12.19",
"sphinx-copybutton==0.5.2",
"sphinx-design==0.6.1",
"sphinx-issues==5.0.1",
"sphinx==8.2.3; python_version >= '3.11'",
"sphinxext-opengraph==0.13.0",
"furo",
"sphinx-copybutton",
"sphinx-design",
"sphinx-issues",
"sphinx>=8.1",
"sphinxext-opengraph",
]
tests = ["pytest<10", "pytest-lazy-fixtures"]
dev = ["marshmallow-sqlalchemy[tests]", "tox", "pre-commit>=3.5,<5.0"]
tests = ["pytest", "pytest-lazy-fixtures"]
dev = [
{ include-group = "tests" },
"tox",
"tox-uv",
"pre-commit>=3.5,<5.0",
]

[tool.uv]
default-groups = ["dev"]

[build-system]
requires = ["flit_core<4"]
Expand Down
7 changes: 3 additions & 4 deletions src/marshmallow_sqlalchemy/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import functools
import inspect
import uuid
from collections.abc import Callable
from typing import (
TYPE_CHECKING,
Any,
Callable,
Literal,
Union,
cast,
overload,
)
Expand All @@ -17,7 +16,7 @@
try:
from typing import TypeAlias, TypeGuard
except ImportError:
from typing_extensions import TypeAlias, TypeGuard
from typing import TypeAlias, TypeGuard

import marshmallow as ma
import sqlalchemy as sa
Expand All @@ -40,7 +39,7 @@
_FieldPartial: TypeAlias = Callable[[], fields.Field]
# TODO: Use more specific type for second argument
_FieldClassFactory: TypeAlias = Callable[
["ModelConverter", Any], Union[type[fields.Field], _FieldPartial]
["ModelConverter", Any], type[fields.Field] | _FieldPartial
]


Expand Down
6 changes: 3 additions & 3 deletions src/marshmallow_sqlalchemy/load_instance_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import importlib.metadata
from collections.abc import Iterable, Mapping, Sequence
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Union, cast
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast

import marshmallow as ma
from sqlalchemy.ext.declarative import DeclarativeMeta
Expand All @@ -21,8 +21,8 @@
if TYPE_CHECKING:
from sqlalchemy.orm import Session

_LoadDataV3 = Union[Mapping[str, Any], Iterable[Mapping[str, Any]]]
_LoadDataV4 = Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]
_LoadDataV3 = Mapping[str, Any] | Iterable[Mapping[str, Any]]
_LoadDataV4 = Mapping[str, Any] | Sequence[Mapping[str, Any]]
_LoadDataT = TypeVar("_LoadDataT", _LoadDataV3, _LoadDataV4)
_ModelType = TypeVar("_ModelType", bound=DeclarativeMeta)

Expand Down
12 changes: 6 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tox]
envlist=
lint
py{39,310,311,312,313}-marshmallow3
py313-marshmallowdev
py39-lowest
py{310,311,312,313,314}-marshmallow3
py314-marshmallowdev
py310-lowest
mypy-marshmallow{3,dev}
docs

[testenv]
extras = tests
dependency_groups = tests
deps =
marshmallow3: marshmallow>=3.18.0,<4.0.0
marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz
Expand All @@ -29,14 +29,14 @@ skip_install = true
commands = pre-commit run --all-files

[testenv:docs]
extras = docs
dependency_groups = docs
commands = sphinx-build docs/ docs/_build {posargs}

; Below tasks are for development only (not run in CI)

[testenv:docs-serve]
deps = sphinx-autobuild
extras = docs
dependency_groups = docs
commands = sphinx-autobuild --port=0 --open-browser --delay=2 docs/ docs/_build {posargs} --watch src --watch CONTRIBUTING.rst --watch README.rst

[testenv:readme-serve]
Expand Down
Loading