From d1b29ba44edcbfec736969d54e7790bcbc28a9be Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Fri, 16 Jan 2026 11:32:14 -0500 Subject: [PATCH 1/9] Add django optional dependency group and add new undate.django module --- pyproject.toml | 3 +++ src/undate/django/__init__.py | 0 2 files changed, 3 insertions(+) create mode 100644 src/undate/django/__init__.py diff --git a/pyproject.toml b/pyproject.toml index fcebbbd..e89bc94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,8 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Framework :: Django", + "Framework :: Django :: 5.2", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: Apache Software License", @@ -53,6 +55,7 @@ classifiers = [ [project.optional-dependencies] docs = ["sphinx>=7.0.0", "alabaster", "myst-parser", "myst-parser[linkify]"] +django = ["django>=5.2"] test = ["pytest>=7.2", "pytest-ordering", "pytest-cov"] notebooks = ["jupyterlab", "pandas", "treon", "altair"] check = ["undate[docs]", "undate[notebooks]", "mypy", "ruff"] diff --git a/src/undate/django/__init__.py b/src/undate/django/__init__.py new file mode 100644 index 0000000..e69de29 From 9995a9515164ef329a05976453eda78e1c0c3aa5 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Fri, 16 Jan 2026 11:38:11 -0500 Subject: [PATCH 2/9] Add django to unit test build matrix --- .github/workflows/unit_tests.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index fc93c1b..d37508b 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -25,6 +25,9 @@ jobs: strategy: matrix: python: ["3.10", "3.11", "3.12", "3.13"] + django: [0, "5.2"] # add more versions as we add support + # exclude incompatible python+django combinations if needed + # OR limit django+python to specific combinations to avoid too many builds defaults: run: working-directory: . @@ -40,8 +43,11 @@ jobs: cache: 'pip' cache-dependency-path: '**/pyproject.toml' - - name: Install package with dependencies - run: pip install -e ".[test]" + # test with and without django based on build matrix + - name: Install package with dependencies (and optionally django) + run: | + if [ "${{ matrix.django }}" -gt "0"]; then pip install -q Django==${{ matrix.django }} pytest-django; fi + pip install -e '.[test]' # for all versions but the one we use for code coverage, run normally - name: Run unit tests without code coverage From 8618048f1e51edb8a17f1591ea7e00ef338f7cc5 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Fri, 16 Jan 2026 11:49:56 -0500 Subject: [PATCH 3/9] Document optional django install --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index c1b662d..928be95 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,14 @@ Use the `@name` notation to specify the branch or tag; e.g., to install developm pip install git+https://github.com/dh-tech/undate-python@develop#egg=undate ``` +### Optional Django Support (PRELIMINARY / IN PROGRESS) + +To install with optional Django integration field support: +```console +pip install undate[django] +``` + + ## Example Usage Often humanities and cultural data include imprecise or uncertain From e42bdf88cc0a845338ba37eef0688ee073db05b2 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Fri, 16 Jan 2026 11:56:01 -0500 Subject: [PATCH 4/9] Add django pytest skip decorators & placeholder unit tests to confirm --- src/undate/test_utils.py | 26 ++++++++++++++++++++++++++ tests/test_django/test_django_setup.py | 16 ++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/undate/test_utils.py create mode 100644 tests/test_django/test_django_setup.py diff --git a/src/undate/test_utils.py b/src/undate/test_utils.py new file mode 100644 index 0000000..c67e7a3 --- /dev/null +++ b/src/undate/test_utils.py @@ -0,0 +1,26 @@ +""" +Utility decorators for unit tests that require django to be installed, +or not installed. To use, import into unit test and apply +to test method or class: + +```python + +from undate.test_utils import skipif_no_django, skipif_django + +@skipif_no_django +def test_django_functionality(): + .... +``` + +""" + +import pytest + +try: + import django +except ImportError: + django = None + +skipif_no_django = pytest.mark.skipif(django is None, reason="requires Django") + +skipif_django = pytest.mark.skipif(django, reason="requires no Django") diff --git a/tests/test_django/test_django_setup.py b/tests/test_django/test_django_setup.py new file mode 100644 index 0000000..9fa39a2 --- /dev/null +++ b/tests/test_django/test_django_setup.py @@ -0,0 +1,16 @@ +try: + import django +except ImportError: + django = None + +from undate.test_utils import skipif_no_django, skipif_django + + +@skipif_no_django +def test_django(): + assert django is not None + + +@skipif_django +def test_no_django(): + assert django is None From 0830ef3fc810b350553cd926cf4d4fbd820da5c6 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Fri, 16 Jan 2026 12:08:35 -0500 Subject: [PATCH 5/9] Add typing to optional django import --- src/undate/test_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/undate/test_utils.py b/src/undate/test_utils.py index c67e7a3..3cc8bdb 100644 --- a/src/undate/test_utils.py +++ b/src/undate/test_utils.py @@ -15,12 +15,14 @@ def test_django_functionality(): """ import pytest +from types import ModuleType +django: ModuleType | None = None try: - import django + import django # type: ignore[import-not-found, no-redef] except ImportError: - django = None + pass skipif_no_django = pytest.mark.skipif(django is None, reason="requires Django") -skipif_django = pytest.mark.skipif(django, reason="requires no Django") +skipif_django = pytest.mark.skipif(django is not None, reason="requires no Django") From f2237ae4418b75f522d279205ff1e95b7a499cc8 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Fri, 16 Jan 2026 12:10:32 -0500 Subject: [PATCH 6/9] Require newer version of numpy and remove deprecated typing plugin --- pyproject.toml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e89bc94..454e12b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,8 @@ docs = ["sphinx>=7.0.0", "alabaster", "myst-parser", "myst-parser[linkify]"] django = ["django>=5.2"] test = ["pytest>=7.2", "pytest-ordering", "pytest-cov"] notebooks = ["jupyterlab", "pandas", "treon", "altair"] -check = ["undate[docs]", "undate[notebooks]", "mypy", "ruff"] +# numpy 2.3+ needed for removal of deperecated typing plugin +check = ["undate[docs]", "undate[notebooks]", "mypy", "ruff", "numpy>=2.3",] dev = [ "pre-commit>=2.20.0", "twine", @@ -90,6 +91,3 @@ markers = [ "last : run marked tests after all others", "first : run marked tests before all others", ] - -[tool.mypy] -plugins = ["numpy.typing.mypy_plugin"] From b2084d0cfa81e2e2673f8b3f712f81f103603aa6 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Fri, 16 Jan 2026 12:13:37 -0500 Subject: [PATCH 7/9] Change non-django matrix build check, per coderabbitai review --- .github/workflows/unit_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index d37508b..1d3f862 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -25,7 +25,7 @@ jobs: strategy: matrix: python: ["3.10", "3.11", "3.12", "3.13"] - django: [0, "5.2"] # add more versions as we add support + django: ["NO_DJANGO", "5.2"] # add more versions as we add support # exclude incompatible python+django combinations if needed # OR limit django+python to specific combinations to avoid too many builds defaults: @@ -46,7 +46,7 @@ jobs: # test with and without django based on build matrix - name: Install package with dependencies (and optionally django) run: | - if [ "${{ matrix.django }}" -gt "0"]; then pip install -q Django==${{ matrix.django }} pytest-django; fi + if [ "${{ matrix.django }}" != "NO_DJANGO"]; then pip install -q Django==${{ matrix.django }} pytest-django; fi pip install -e '.[test]' # for all versions but the one we use for code coverage, run normally From dc051241b2c549fb397658b5f3f0c756a3a6f457 Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Fri, 16 Jan 2026 12:14:36 -0500 Subject: [PATCH 8/9] Drop numpy version from check (conflicts with python versions in build) --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 454e12b..16f71a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,8 +58,7 @@ docs = ["sphinx>=7.0.0", "alabaster", "myst-parser", "myst-parser[linkify]"] django = ["django>=5.2"] test = ["pytest>=7.2", "pytest-ordering", "pytest-cov"] notebooks = ["jupyterlab", "pandas", "treon", "altair"] -# numpy 2.3+ needed for removal of deperecated typing plugin -check = ["undate[docs]", "undate[notebooks]", "mypy", "ruff", "numpy>=2.3",] +check = ["undate[docs]", "undate[notebooks]", "mypy", "ruff"] dev = [ "pre-commit>=2.20.0", "twine", From 729e6d8c242dea05f309f8fc70f63686dc2afb2c Mon Sep 17 00:00:00 2001 From: rlskoeser Date: Fri, 16 Jan 2026 12:19:20 -0500 Subject: [PATCH 9/9] Add pip to check requirements, since not installed with uv by default --- pyproject.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 16f71a0..ec6e469 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,13 @@ docs = ["sphinx>=7.0.0", "alabaster", "myst-parser", "myst-parser[linkify]"] django = ["django>=5.2"] test = ["pytest>=7.2", "pytest-ordering", "pytest-cov"] notebooks = ["jupyterlab", "pandas", "treon", "altair"] -check = ["undate[docs]", "undate[notebooks]", "mypy", "ruff"] +check = [ + "undate[docs]", + "undate[notebooks]", + "mypy", + "ruff", + "pip>=25.3", +] dev = [ "pre-commit>=2.20.0", "twine",