From 20ecb5e69332e89ede92366e14aad554185d050e Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Fri, 29 Mar 2024 20:25:02 +0100 Subject: [PATCH] Accept `datasource` attribute on `DatasourceItem`, but don't process it > When I try to explore datasources it always fail with a TypeError. > No idea why this happens. Exception: TypeError: DatasourceItem.__init__() got an unexpected keyword argument 'datasource' --- CHANGES.rst | 2 ++ grafana_wtf/model.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index c53d8b0..d5f4626 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,8 @@ in progress - Add subcommand ``explore permissions``. Thanks, @meyerder. - Added support for Python 3.12 - Removed support for Python 3.7 +- Accept ``datasource`` attribute on ``DatasourceItem``, but + don't process it. Thanks, @apepojken. 2024-03-07 0.18.0 ================= diff --git a/grafana_wtf/model.py b/grafana_wtf/model.py index fd27fe4..1d5d795 100644 --- a/grafana_wtf/model.py +++ b/grafana_wtf/model.py @@ -4,7 +4,7 @@ import dataclasses import logging from collections import OrderedDict -from typing import Dict, List, Optional +from typing import Dict, List, Optional, Any from urllib.parse import urljoin from munch import Munch @@ -163,6 +163,15 @@ class DatasourceItem: type: Optional[str] = None url: Optional[str] = None + # The `datasource` attribute slot compensates for runtime errors reported by @apepojken. + # TypeError: DatasourceItem.__init__() got an unexpected keyword argument 'datasource' + # https://github.com/panodata/grafana-wtf/issues/110 + + # However, currently it is not processed. It would be good to + # have a data sample in order to get the implementation right. + # https://github.com/panodata/grafana-wtf/pull/131 + datasource: Optional[Any] = None + @classmethod def from_payload(cls, payload: any): if isinstance(payload, Munch):