From 396d299ad036321f3e42638659dc65d9ffc8cb4a Mon Sep 17 00:00:00 2001 From: Alasdair Wilson Date: Thu, 16 Apr 2026 13:08:54 +0100 Subject: [PATCH] Add compatibility shims for legacy imports --- tests/unit/test_legacy_module_shims.py | 23 +++++++++++++++++++++++ vertex/IsaricAnalytics.py | 11 +++++++++++ vertex/IsaricDraw.py | 11 +++++++++++ vertex/getREDCapData.py | 11 +++++++++++ 4 files changed, 56 insertions(+) create mode 100644 tests/unit/test_legacy_module_shims.py create mode 100644 vertex/IsaricAnalytics.py create mode 100644 vertex/IsaricDraw.py create mode 100644 vertex/getREDCapData.py diff --git a/tests/unit/test_legacy_module_shims.py b/tests/unit/test_legacy_module_shims.py new file mode 100644 index 0000000..27addf9 --- /dev/null +++ b/tests/unit/test_legacy_module_shims.py @@ -0,0 +1,23 @@ +import importlib +import sys + +import pytest + + +@pytest.mark.parametrize( + ("legacy_module", "target_module", "exported_name"), + [ + ("vertex.IsaricAnalytics", "IsaricAnalytics", "descriptive_table"), + ("vertex.IsaricDraw", "IsaricDraw", "fig_text"), + ("vertex.getREDCapData", "getREDCapData", "get_records"), + ], +) +def test_legacy_vertex_module_shims_warn_and_reexport(monkeypatch, legacy_module, target_module, exported_name): + target = importlib.import_module(f"isaricanalytics.{target_module}") + monkeypatch.delitem(sys.modules, legacy_module, raising=False) + + namespace = {} + with pytest.warns(DeprecationWarning, match=legacy_module): + exec(f"from {legacy_module} import *", namespace, namespace) + + assert namespace[exported_name] is getattr(target, exported_name) diff --git a/vertex/IsaricAnalytics.py b/vertex/IsaricAnalytics.py new file mode 100644 index 0000000..6da84af --- /dev/null +++ b/vertex/IsaricAnalytics.py @@ -0,0 +1,11 @@ +"""Deprecated compatibility shim for legacy ``vertex.IsaricAnalytics`` imports.""" + +import warnings as _warnings + +_warnings.warn( + "vertex.IsaricAnalytics is deprecated; import from isaricanalytics.IsaricAnalytics instead.", + DeprecationWarning, + stacklevel=2, +) + +from isaricanalytics.IsaricAnalytics import * # noqa: F401,F403,E402 diff --git a/vertex/IsaricDraw.py b/vertex/IsaricDraw.py new file mode 100644 index 0000000..57fea38 --- /dev/null +++ b/vertex/IsaricDraw.py @@ -0,0 +1,11 @@ +"""Deprecated compatibility shim for legacy ``vertex.IsaricDraw`` imports.""" + +import warnings as _warnings + +_warnings.warn( + "vertex.IsaricDraw is deprecated; import from isaricanalytics.IsaricDraw instead.", + DeprecationWarning, + stacklevel=2, +) + +from isaricanalytics.IsaricDraw import * # noqa: F401,F403,E402 diff --git a/vertex/getREDCapData.py b/vertex/getREDCapData.py new file mode 100644 index 0000000..6430d69 --- /dev/null +++ b/vertex/getREDCapData.py @@ -0,0 +1,11 @@ +"""Deprecated compatibility shim for legacy ``vertex.getREDCapData`` imports.""" + +import warnings as _warnings + +_warnings.warn( + "vertex.getREDCapData is deprecated; import from isaricanalytics.getREDCapData instead.", + DeprecationWarning, + stacklevel=2, +) + +from isaricanalytics.getREDCapData import * # noqa: F401,F403,E402