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


##########
clients/client-python/gravitino/dto/authorization/role_dto.py:
##########
@@ -0,0 +1,119 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+from dataclasses import dataclass, field
+from typing import Optional
+
+from dataclasses_json import config, dataclass_json
+
+from gravitino.api.authorization.role import Role
+from gravitino.api.authorization.securable_objects import SecurableObject
+from gravitino.dto.audit_dto import AuditDTO
+from gravitino.dto.authorization.securable_object_dto import SecurableObjectDTO
+
+
+@dataclass_json
+@dataclass
+class RoleDTO(Role):
+    """Represents a Role Data Transfer Object (DTO)."""
+
+    _name: str = field(metadata=config(field_name="name"))
+    _properties: Optional[dict[str, str]] = field(
+        default=None, metadata=config(field_name="properties")
+    )
+    _securable_objects: list[SecurableObjectDTO] = field(
+        default_factory=list, metadata=config(field_name="securableObjects")
+    )
+    _audit: Optional[AuditDTO] = field(
+        default=None, metadata=config(field_name="audit")
+    )
+
+    def __eq__(self, other: object) -> bool:
+        if not isinstance(other, RoleDTO):
+            return False
+        return (
+            self._name == other._name
+            and self._properties == other._properties
+            and self._audit == other._audit
+        )
+
+    def __hash__(self) -> int:
+        return hash(
+            (
+                self._name,
+                frozenset(self._properties.items()) if self._properties else 
None,
+                self._audit,
+            )
+        )

Review Comment:
   Same reasoning as above — the Java `RoleDTO` does not override 
`equals/hashCode` either. DTOs are data carriers and don't need 
collection-based equality. Keeping the Python implementation consistent with 
the Java side.



-- 
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