From b25081353833d98693ba6b6a50a8a0f530bcf9f5 Mon Sep 17 00:00:00 2001 From: Stef Pletinck Date: Fri, 19 Dec 2025 11:38:49 +0100 Subject: [PATCH] Add support for integer type in CORE Obelisk CORE version 2.3.0 added support for `integer` and `integer[]`, with `number` variants remaining as a float-or-integer supertype. Usage of these types affords more compact storage and faster querying --- src/obelisk/asynchronous/core.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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: