Copilot commented on code in PR #11210:
URL: https://github.com/apache/gravitino/pull/11210#discussion_r3301034204


##########
clients/client-python/gravitino/client/dto_converters.py:
##########
@@ -325,3 +332,20 @@ def to_tag_update_request(
             return 
TagUpdateRequest.RemoveTagPropertyRequest(change.removed_property)
 
         raise IllegalArgumentException(f"Unknown change type: {type(change)}")
+
+    @staticmethod
+    def to_privilege_dto(privilege: Privilege) -> PrivilegeDTO:
+        return PrivilegeDTO(privilege.name(), privilege.condition())
+
+    @staticmethod
+    def from_privilege_dto(dto: PrivilegeDTO) -> Privilege:
+        return dto
+
+    @staticmethod
+    def to_securable_object_dto(obj: SecurableObject) -> SecurableObjectDTO:
+        privilege_dtos = [DTOConverters.to_privilege_dto(p) for p in 
obj.privileges()]
+        return SecurableObjectDTO(obj.full_name(), obj.type(), privilege_dtos)
+
+    @staticmethod
+    def from_securable_object_dto(dto: SecurableObjectDTO) -> SecurableObject:
+        return SecurableObjects.parse(dto.full_name(), dto.type(), 
dto.privileges())

Review Comment:
   DTOConverters.from_securable_object_dto() returns a 
SecurableObjects.SecurableObjectImpl. That class currently implements __hash__ 
as hash((super().__hash__(), self._privileges)), but self._privileges is a list 
(unhashable) so calling hash() on the returned object will raise TypeError. 
Either fix SecurableObjectImpl.__hash__ to hash an immutable privilege 
collection (e.g., tuple/frozenset) or avoid returning a type with a broken 
__hash__ here.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to