Skip to content

Commit

Permalink
Accept datasource attribute on DatasourceItem, but don't process it
Browse files Browse the repository at this point in the history
> 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'
  • Loading branch information
amotl committed Mar 30, 2024
1 parent 76e1abd commit 20ecb5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=================
Expand Down
11 changes: 10 additions & 1 deletion grafana_wtf/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 20ecb5e

Please sign in to comment.