-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
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 = TrueI 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels