From f011ba70c8137f2db09791ed74e4041f417d811a Mon Sep 17 00:00:00 2001 From: sea-shunned Date: Mon, 16 Sep 2024 17:17:47 +0100 Subject: [PATCH] Allow null default values, and unify dtype storage --- aiod_registry/schema.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/aiod_registry/schema.py b/aiod_registry/schema.py index a7f3230..ed8071c 100644 --- a/aiod_registry/schema.py +++ b/aiod_registry/schema.py @@ -82,6 +82,19 @@ def extract_arg_type(self): self._dtype = type(self.value[0]) else: self._dtype = type(self.value) + # If None, we need a dtype to poss cast to when dealing with GUIs + if self.value is None: + if self.dtype is None: + raise ValueError( + f"Parameter {self.name} needs a dtype if default value is None!" + ) + else: + if getattr(builtins, self.dtype, None) is None: + raise ValueError( + f"Parameter {self.name} has an invalid dtype ({self.dtype})!" + ) + else: + self.dtype = self._dtype return self