We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cac7533 commit e5609c2Copy full SHA for e5609c2
src/databricks/sql/telemetry/utils.py
@@ -1,8 +1,7 @@
1
import json
2
from enum import Enum
3
-from dataclasses import asdict
+from dataclasses import asdict, is_dataclass
4
from abc import ABC
5
-from typing import Any
6
7
8
class JsonSerializableMixin(ABC):
@@ -13,6 +12,11 @@ def to_json(self) -> str:
13
12
Convert the object to a JSON string, excluding None values.
14
Handles Enum serialization and filters out None values from the output.
15
"""
+ if not is_dataclass(self):
16
+ raise TypeError(
17
+ f"{self.__class__.__name__} must be a dataclass to use JsonSerializableMixin"
18
+ )
19
+
20
return json.dumps(
21
asdict(
22
self,
0 commit comments