diff --git a/.github/workflows/test-upstream.yaml b/.github/workflows/test-upstream.yaml index 1aab649c..c767647a 100644 --- a/.github/workflows/test-upstream.yaml +++ b/.github/workflows/test-upstream.yaml @@ -118,7 +118,10 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install poetry - run: pipx install poetry + run: pipx install poetry==1.* + + - name: Check Poetry version + run: poetry --version - name: Install dynamic versioning plugin run: poetry self add "poetry-dynamic-versioning[plugin]" diff --git a/README.md b/README.md index 4020b7c9..d48c3cc2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![PyPIDownloadsMonth](https://img.shields.io/pypi/dm/linkml-runtime?logo=PyPI&color=blue)](https://pypi.org/project/linkml-runtime) [![codecov](https://codecov.io/gh/linkml/linkml-runtime/branch/main/graph/badge.svg?token=FOBHNSK5WG)](https://codecov.io/gh/linkml/linkml-runtime) -Runtime support for linkml generated data classes +Runtime support for linkml generated data classes. ## About diff --git a/linkml_runtime/utils/dataclass_extensions_376.py b/linkml_runtime/utils/dataclass_extensions_376.py new file mode 100644 index 00000000..4321855d --- /dev/null +++ b/linkml_runtime/utils/dataclass_extensions_376.py @@ -0,0 +1,15 @@ +import sys +import warnings +import dataclasses + +warnings.warn( + "The LinkML dataclass extension patch is deprecated and will be removed in a future release.\n" + "If you're currently using Python < 3.13, where this patch still applies, you should:\n" + " • Upgrade your LinkML tooling to version >= 1.9.0 (which no longer needs this patch), OR\n" + " • Migrate to Pydantic models if you're using LinkML's generated classes at runtime.\n", + DeprecationWarning, + stacklevel=2 +) + +dataclasses_init_fn_with_kwargs = dataclasses._init_fn +DC_CREATE_FN = False \ No newline at end of file diff --git a/tests/test_issues/test_dataclass_extensions_376.py b/tests/test_issues/test_dataclass_extensions_376.py new file mode 100644 index 00000000..093a233e --- /dev/null +++ b/tests/test_issues/test_dataclass_extensions_376.py @@ -0,0 +1,27 @@ +import sys +import pytest +import importlib.util +import dataclasses + + +def import_patch_module(): + """Fresh import to ensure warning is triggered""" + spec = importlib.util.find_spec("linkml_runtime.utils.dataclass_extensions_376") + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + return mod + +def test_patch_module_emits_deprecation_warning(): + """All Python versions: emits DeprecationWarning and defines compatibility symbols""" + with pytest.warns(DeprecationWarning): + mod = import_patch_module() + + assert hasattr(mod, "DC_CREATE_FN") + assert hasattr(mod, "dataclasses_init_fn_with_kwargs") + assert mod.DC_CREATE_FN is False + + # Check consistency with actual dataclasses module + init_fn = getattr(dataclasses, "_init_fn", None) + assert mod.dataclasses_init_fn_with_kwargs == init_fn + +