From 3d07a5c9dd7c6e5254116d0b83014d1efde5ccce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Wed, 2 Aug 2023 12:06:20 +0200 Subject: [PATCH] DataService: converting ints to floats if current value is a float --- src/pyDataInterface/data_service/data_service.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pyDataInterface/data_service/data_service.py b/src/pyDataInterface/data_service/data_service.py index 13e473d..442d44c 100644 --- a/src/pyDataInterface/data_service/data_service.py +++ b/src/pyDataInterface/data_service/data_service.py @@ -70,7 +70,13 @@ class DataService(rpyc.Service): self._initialised = True def __setattr__(self, __name: str, __value: Any) -> None: + current_value = getattr(self, __name, None) + # parse ints into floats if current value is a float + if isinstance(current_value, float) and isinstance(__value, int): + __value = float(__value) + super().__setattr__(__name, __value) + if self.__dict__.get("_initialised") and not __name == "_initialised": for callback in self._callbacks: callback(__name, __value)