diff --git a/Options.py b/Options.py index 1a7faf02..f31c7e6f 100644 --- a/Options.py +++ b/Options.py @@ -148,17 +148,28 @@ class Choice(Option): return cls.from_text(str(data)) def __eq__(self, other): - if type(other) == str: + if isinstance(other, str): assert other in self.options return other == self.current_key - elif type(other) == int: + elif isinstance(other, int): assert other in self.name_lookup return other == self.value - elif type(other) == bool: + elif isinstance(other, bool): return other == bool(self.value) else: raise TypeError(f"Can't compare {self.__class__.__name__} with {other.__class__.__name__}") + def __ne__(self, other): + if isinstance(other, str): + assert other in self.options + return other != self.current_key + elif isinstance(other, int): + assert other in self.name_lookup + return other != self.value + elif isinstance(other, bool): + return other != bool(self.value) + else: + raise TypeError(f"Can't compare {self.__class__.__name__} with {other.__class__.__name__}") class Range(Option, int): range_start = 0