diff --git a/dataretrieval/utils.py b/dataretrieval/utils.py index 7bb03a69..3e6f4e84 100644 --- a/dataretrieval/utils.py +++ b/dataretrieval/utils.py @@ -202,7 +202,15 @@ def _attach_datetime_columns(df: pd.DataFrame) -> pd.DataFrame: class BaseMetadata: - """Base class for metadata. + """Base class for the metadata returned alongside a service's data. + + A concrete value object holding the response URL, query time, and headers; + the modern ``waterdata`` getters return it directly. + + ``site_info`` and ``variable_info`` are legacy hooks: the ``nwis`` / ``wqp`` + metadata subclasses override them to look up site (or, historically, + variable) details for the query. They are not part of the modern + ``waterdata`` contract, so on the base they raise ``NotImplementedError``. Attributes ---------- @@ -212,7 +220,6 @@ class BaseMetadata: Response elapsed time header: httpx.Headers Response headers - """ def __init__(self, response) -> None: diff --git a/dataretrieval/wqp.py b/dataretrieval/wqp.py index 0e0adc8d..3826986d 100644 --- a/dataretrieval/wqp.py +++ b/dataretrieval/wqp.py @@ -676,6 +676,13 @@ def site_info(self) -> tuple[DataFrame, WQP_Metadata] | None: return None return what_sites(siteid=siteid) + @property + def variable_info(self) -> None: + """WQP exposes no variable/parameter catalog through metadata, so this + is always ``None`` (overriding the :class:`~dataretrieval.utils.BaseMetadata` + stub, which would otherwise raise ``NotImplementedError``).""" + return None + def _check_kwargs(kwargs): """Private function to check kwargs for unsupported parameters.""" diff --git a/tests/wqp_test.py b/tests/wqp_test.py index 83b69ff4..f86b7f5e 100644 --- a/tests/wqp_test.py +++ b/tests/wqp_test.py @@ -272,6 +272,13 @@ def test_wqp_metadata_site_info_is_accessible_property(): assert _wqp_metadata().site_info is None # must NOT raise +def test_wqp_metadata_variable_info_is_none(): + """Regression: WQP has no variable catalog, so ``variable_info`` must + return ``None`` rather than inheriting (and raising) the + ``BaseMetadata.variable_info`` NotImplementedError stub.""" + assert _wqp_metadata().variable_info is None # must NOT raise + + def test_wqp_metadata_site_info_routes_to_what_sites(monkeypatch): """When the query carried a ``siteid`` (WQP's site identifier), ``site_info`` delegates to ``wqp.what_sites`` with that identifier."""