type hints with Enum do not work
I found out, that we cannot define READ_WRITE Enum attribute with type hints:
from enum import Enum
from tango.server import Device, attribute
from tango.test_context import DeviceTestContext
class MyEnum(Enum):
ZERO = 0
ONE = 1
TWO = 2
class MyDevice(Device):
_val = MyEnum.ZERO
@attribute()
def enum_attr(self) -> MyEnum:
return self._val
@enum_attr.write
def set_enum_attr(self, new_val):
self._val = MyEnum(new_val)
if __name__ == '__main__':
with DeviceTestContext(MyDevice) as test:
print(test.LensMode)
Does not work, due to "__get_attribute_type_from_hint" is called twice: ones, when we parce read method and the second time, when we parce write method. This leads to call of "set_enum_labels" method of att_prop object. Which, in fact does not set, but append labels (see cppTango#1385 (closed)).
Edited by Yury Matveev