Skip to content

Commit 73b125a

Browse files
committed
fix: generalize eq methods
1 parent 07e1fe2 commit 73b125a

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

tableauserverclient/models/permissions_item.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ def __repr__(self):
4545
return "<Enum Capability: AddComment | ChangeHierarchy | ChangePermission ... (17 more) >"
4646

4747

48-
class PermissionsRule(object):
48+
class PermissionsRule:
4949
def __init__(self, grantee: ResourceReference, capabilities: Dict[str, str]) -> None:
5050
self.grantee = grantee
5151
self.capabilities = capabilities
5252

5353
def __repr__(self):
5454
return "<PermissionsRule grantee={}, capabilities={}>".format(self.grantee, self.capabilities)
5555

56-
def __eq__(self, other: "PermissionsRule") -> bool:
56+
def __eq__(self, other: object) -> bool:
57+
if not hasattr(other, "grantee") or not hasattr(other, "capabilities"):
58+
return False
5759
return self.grantee == other.grantee and self.capabilities == other.capabilities
5860

5961
def __and__(self, other: "PermissionsRule") -> "PermissionsRule":

tableauserverclient/models/reference_item.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ def __str__(self):
88

99
__repr__ = __str__
1010

11-
def __eq__(self, other):
11+
def __eq__(self, other: object):
12+
if not hasattr(other, 'id') or not hasattr(other, 'tag_name'):
13+
return False
1214
return (self.id == other.id) and (self.tag_name == other.tag_name)
1315

1416
@property

0 commit comments

Comments
 (0)