From 2692604c091a3e0d87e2535474d1f180c86da3d6 Mon Sep 17 00:00:00 2001 From: Alchav <59858495+Alchav@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:40:16 -0500 Subject: [PATCH] Core: String comparison with FreeText class (#2942) --- Options.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Options.py b/Options.py index f19c042f..144220c8 100644 --- a/Options.py +++ b/Options.py @@ -180,6 +180,14 @@ class FreeText(Option[str]): 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