diff --git a/src/obelisk/asynchronous/core.py b/src/obelisk/asynchronous/core.py index 024319f..e9231f7 100644 --- a/src/obelisk/asynchronous/core.py +++ b/src/obelisk/asynchronous/core.py @@ -42,7 +42,7 @@ from obelisk.types.core import IngestMode -DataType = Literal["number", "number[]", "json", "bool", "string"] +DataType = Literal["number", "number[]", "json", "bool", "string", "integer", "integer[]"] """The possible types of data Obelisk can accept""" @@ -113,6 +113,15 @@ def check_metric_type(self) -> Self: ): raise ValueError("Type suffix mismatch, expected value of number[]") + if suffix == "integer" and not isinstance(self.value, int): + raise ValueError("Type suffix mismatch, expected value of type integer") + + if suffix == "integer[]" and ( + type(self.value) is not list + or any([not isinstance(x, int) for x in self.value]) + ): + raise ValueError("Type suffix mismatch, expected value of integer[]") + # Do not check json, most things should be serialisable if suffix == "bool" and type(self.value) is not bool: