Options: more feedback on bad compares (#362)

This commit is contained in:
Fabian Dill
2022-03-31 03:29:45 +02:00
committed by GitHub
parent 0263130126
commit 8337689640

View File

@@ -180,10 +180,10 @@ class Choice(Option[int]):
if isinstance(other, self.__class__):
return other.value == self.value
elif isinstance(other, str):
assert other in self.options, "compared against a str that could never be equal."
assert other in self.options, f"compared against a str that could never be equal. {self} == {other}"
return other == self.current_key
elif isinstance(other, int):
assert other in self.name_lookup, "compared against an int that could never be equal."
assert other in self.name_lookup, f"compared against an int that could never be equal. {self} == {other}"
return other == self.value
elif isinstance(other, bool):
return other == bool(self.value)
@@ -194,10 +194,10 @@ class Choice(Option[int]):
if isinstance(other, self.__class__):
return other.value != self.value
elif isinstance(other, str):
assert other in self.options , "compared against a str that could never be equal."
assert other in self.options , f"compared against a str that could never be equal. {self} != {other}"
return other != self.current_key
elif isinstance(other, int):
assert other in self.name_lookup, "compared against am int that could never be equal."
assert other in self.name_lookup, f"compared against am int that could never be equal. {self} != {other}"
return other != self.value
elif isinstance(other, bool):
return other != bool(self.value)