Skip to content

Commit

Permalink
Core: String comparison with FreeText class (#2942)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alchav authored Mar 12, 2024
1 parent 4bf676e commit 2692604
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ def from_any(cls, data: typing.Any) -> FreeText:
def get_option_name(cls, value: str) -> str:
return value

def __eq__(self, other):
if isinstance(other, self.__class__):
return other.value == self.value
elif isinstance(other, str):
return other == self.value
else:
raise TypeError(f"Can't compare {self.__class__.__name__} with {other.__class__.__name__}")


class NumericOption(Option[int], numbers.Integral, abc.ABC):
default = 0
Expand Down

0 comments on commit 2692604

Please sign in to comment.