Skip to content

Commit

Permalink
fix enum equals method
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Apr 30, 2024
1 parent 8b6b094 commit 752dd79
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/edutap/wallet_google/models/primitives/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ def __new__(cls: type["CamelCaseAliasEnum"], value: str) -> "CamelCaseAliasEnum"
cls._member_names_.append(camel)
return obj

def __eq__(self, other: Enum) -> bool:
def __eq__(self, other: object | Enum) -> bool:
"""Allow comparison with the camelcase value.
take into account that UPPER_CASE and camelCase are equal
"""
if self.value == other.value:
return True
else:
v1 = self.value.lower().replace("_", "")
v2 = other.value.lower().replace("_", "")
return v1 == v2
if isinstance(other, Enum):
if self.value == other.value:
return True
else:
v1 = self.value.lower().replace("_", "")
v2 = other.value.lower().replace("_", "")
return v1 == v2
return False


class Action(CamelCaseAliasEnum):
Expand Down

0 comments on commit 752dd79

Please sign in to comment.