Since finding out I can do:
@lt.setting
def microscope_id(self) -> UUID:
"""A unique identifier for this microscope."""
if self._microscope_id is None:
self._microscope_id = str(uuid4())
return UUID(self._microscope_id)
@microscope_id.setter
def _set_microscope_id(self, uuid: UUID) -> None:
self._microscope_id = str(uuid)
microscope_id.readonly = True
I am realising I can set the other attributes of the descriptor including constraints such as:
@lt.setting
def microscope_id(self) -> UUID:
"""A unique identifier for this microscope."""
if self._microscope_id is None:
self._microscope_id = str(uuid4())
return UUID(self._microscope_id)
@microscope_id.setter
def _set_microscope_id(self, uuid: UUID) -> None:
self._microscope_id = str(uuid)
microscope_id.constraints = {"min_length": 1}
This propagates through to the thing_descriptions. I think if BaseProperty made constraints a @builtins.propertythen it could either validate it with the setter. Or create aset_constraints` so that this is possible:
@lt.setting
def microscope_id(self) -> UUID:
"""A unique identifier for this microscope."""
if self._microscope_id is None:
self._microscope_id = str(uuid4())
return UUID(self._microscope_id)
@microscope_id.setter
def _set_microscope_id(self, uuid: UUID) -> None:
self._microscope_id = str(uuid)
microscope_id.set_constraints(min_length=1)
which feels like nicer syntax.
Since finding out I can do:
I am realising I can set the other attributes of the descriptor including constraints such as:
This propagates through to the
thing_descriptions. I think ifBasePropertymadeconstraints a@builtins.propertythen it could either validate it with the setter. Or create aset_constraints` so that this is possible:which feels like nicer syntax.