From 3beee08b0643bd76960412f60e1fbd21d54741d6 Mon Sep 17 00:00:00 2001 From: kai ru <69238381+kairu-ms@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:03:49 +0800 Subject: [PATCH] Convert int value to float for FloatArg default and blank value. --- src/aaz_dev/command/model/configuration/_arg.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/aaz_dev/command/model/configuration/_arg.py b/src/aaz_dev/command/model/configuration/_arg.py index f609ad39..8f339e3d 100644 --- a/src/aaz_dev/command/model/configuration/_arg.py +++ b/src/aaz_dev/command/model/configuration/_arg.py @@ -614,8 +614,12 @@ def _reformat_base(self, **kwargs): self.enum.reformat(**kwargs) if self.blank: if not isinstance(self.blank.value, float) and not (self.nullable and self.blank.value is None): - raise exceptions.VerificationError( - f"Invalid blank value", details=f"'{self.blank.value}' is not a valid float arg value") + if isinstance(self.blank.value, int): + # frontend will pass an int value when it doesn't have decimal part + self.blank.value = float(self.blank.value) + else: + raise exceptions.VerificationError( + f"Invalid blank value", details=f"'{self.blank.value}' is not a valid float arg value") class CMDFloatArg(CMDFloatArgBase, CMDArg): @@ -624,8 +628,12 @@ def _reformat(self, **kwargs): super()._reformat(**kwargs) if self.default: if not isinstance(self.default.value, float) and not (self.nullable and self.default.value is None): - raise exceptions.VerificationError( - f"Invalid default value", details=f"'{self.default.value}' is not a valid float arg value") + if isinstance(self.default.value, int): + # frontend will pass an int value when it doesn't have decimal part + self.default.value = float(self.default.value) + else: + raise exceptions.VerificationError( + f"Invalid default value", details=f"'{self.default.value}' is not a valid float arg value") # float32