From 8291ce28d0cdd091816d604068d8bc4ad4d744f3 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:42:23 +0100 Subject: [PATCH] implemented name setter --- ayon_api/entity_hub.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ayon_api/entity_hub.py b/ayon_api/entity_hub.py index c4d7c46de..f3094824c 100644 --- a/ayon_api/entity_hub.py +++ b/ayon_api/entity_hub.py @@ -1775,14 +1775,6 @@ def lock(self): def _get_entity_by_id(self, entity_id): return self._entity_hub.get_entity_by_id(entity_id) - def get_name(self): - return self._name - - def set_name(self, name): - self._name = name - - name = property(get_name, set_name) - def get_parent_id(self): """Parent entity id. @@ -1972,7 +1964,17 @@ def get_name(self): ) return self._name - name = property(get_name) + def set_name(self, name): + if not self._supports_name: + raise NotImplementedError( + f"Name is not supported for '{self.entity_type}'." + ) + + if not isinstance(name, str): + raise TypeError("Name must be a string.") + self._name = name + + name = property(get_name, set_name) def get_label(self) -> Optional[str]: if not self._supports_label: