diff --git a/doc/whatsnew.rst b/doc/whatsnew.rst index 725664ce3..a96b11acb 100644 --- a/doc/whatsnew.rst +++ b/doc/whatsnew.rst @@ -7,6 +7,7 @@ Next release ============ - Python 3.12 (released 2023-10-02) is fully supported (:pull:`145`). +- Bugfix: :py:`dsd=...` argument supplied to the SDMX-ML reader ignored in v2.11.0 and later, causing a warning (:pull:`147`; thanks :gh-user:`miccoli` for :issue:`146`). v2.12.0 (2023-10-11) ==================== diff --git a/sdmx/reader/xml/v21.py b/sdmx/reader/xml/v21.py index bfae6847b..3c9f31a8e 100644 --- a/sdmx/reader/xml/v21.py +++ b/sdmx/reader/xml/v21.py @@ -680,7 +680,7 @@ def _message(reader: Reader, elem): # With 'dsd' argument, the message should be structure-specific if ( "StructureSpecific" in elem.tag - and reader.get_single(common.BaseDataStructureDefinition) is None + and reader.get_single(common.BaseDataStructureDefinition, subclass=True) is None ): log.warning(f"xml.Reader got no dsd=… argument for {QName(elem).localname}") ss_without_dsd = True diff --git a/sdmx/tests/test_dataset_ss.py b/sdmx/tests/test_dataset_ss.py index 92dde8908..128810a3d 100644 --- a/sdmx/tests/test_dataset_ss.py +++ b/sdmx/tests/test_dataset_ss.py @@ -1,3 +1,4 @@ +import logging from collections.abc import Mapping import pandas as pd @@ -26,9 +27,13 @@ def msg(self, path, dsd): yield sdmx.read_sdmx(path / self.filename, dsd=dsd) # Tests for every class - def test_msg(self, path, dsd): + def test_msg(self, caplog, path, dsd): # The message can be parsed - sdmx.read_sdmx(path / self.filename, dsd=dsd) + with caplog.at_level(logging.WARNING): + sdmx.read_sdmx(path / self.filename, dsd=dsd) + + # No warnings are emitted per missing dsd= argument (khaeru/sdmx#146) + assert [] == caplog.messages def test_structured_by(self, dsd, msg): # The DSD was used to parse the message