DataService: converting ints to floats if current value is a float

This commit is contained in:
Mose Müller
2023-08-02 12:06:20 +02:00
parent 07d9066be9
commit 3d07a5c9dd

View File

@ -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)