From 138f2e62de6a0b860d21ba8c33f6dac26c0dc998 Mon Sep 17 00:00:00 2001 From: Martin Wagner Date: Mon, 28 Oct 2024 23:54:40 +0100 Subject: [PATCH] Deprecates core_loaders.etree_loader --- _delb/plugins/core_loaders.py | 9 +++++++++ tests/test_loaders.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/_delb/plugins/core_loaders.py b/_delb/plugins/core_loaders.py index 367f7894..9872c96f 100644 --- a/_delb/plugins/core_loaders.py +++ b/_delb/plugins/core_loaders.py @@ -26,6 +26,7 @@ from io import IOBase, UnsupportedOperation from pathlib import Path from typing import TYPE_CHECKING, cast, Any +from warnings import warn from lxml import etree @@ -60,8 +61,16 @@ def etree_loader(data: Any, config: SimpleNamespace) -> LoaderResult: :class:`lxml.etree._ElementTree` instances. """ if isinstance(data, etree._ElementTree): + warn( + "lxml's etree models will not be usable inputs with the contributed core loaders.", + category=DeprecationWarning, + ) return deepcopy(data) if isinstance(data, etree._Element): + warn( + "lxml's etree models will not be usable inputs with the contributed core loaders.", + category=DeprecationWarning, + ) return etree.ElementTree( element=deepcopy(data), parser=config.parser_options._make_parser() ) diff --git a/tests/test_loaders.py b/tests/test_loaders.py index 43a8a5dc..45c65690 100644 --- a/tests/test_loaders.py +++ b/tests/test_loaders.py @@ -23,7 +23,8 @@ def test_etree_loader(): tree = etree.parse(str(TEST_FILE)) root = tree.getroot() - document = Document(root) + with pytest.deprecated_call(): + document = Document(root) assert document.root._etree_obj is not root assert document.source_url is None