Take attribute and property type from type hint
Created by: stanislaw55
Hi, I wanted to share an idea. Right now, when addint attribute (or property) in device class, one need to specify it in constructor like this:
attr = attribute(
dtype="DevState",
label="Heat Absorber",
access=AttrWriteType.READ,
doc="State of the Heat Absorber",
)
when adding type hint support (for mypy, in example), one has to duplicate the type definition like this
attr: DevState = attribute(
dtype="DevState",
label="Heat Absorber",
access=AttrWriteType.READ,
doc="State of the Heat Absorber",
)
It would be cool to just define attribute like this
attr: DevState = attribute(
label="Heat Absorber",
access=AttrWriteType.READ,
doc="State of the Heat Absorber",
)
So type is taken from Python's type hint. It would be super nice if it would work with spectrum and image attributes
attr: List[float] = attribute(
label="Bar",
access=AttrWriteType.READ,
doc="Bar attribute",
)
attr: List[List[bool]] = attribute(
label="Foo",
access=AttrWriteType.READ,
doc="Foo attribute",
)
and even max_dim_x and max_dim_y when using Tuple
Edited by Anton Joubert