1
0
Fork 0

Make check results hashable

This commit is contained in:
Maurizio Porrato 2023-08-16 16:39:07 +01:00
parent e99c181021
commit f3eb3d1d09
1 changed files with 14 additions and 0 deletions

View File

@ -30,9 +30,23 @@ class CheckResult:
def __int__(self):
return self.severity
def __eq__(self, other):
return (self.kind, self.reason, self.check, self.origin) == (
other.kind,
other.reason,
other.check,
other.origin,
)
def __ne__(self, other):
return not self == other
def __lt__(self, other):
return int(self) < int(other)
def __hash__(self):
return hash((self.kind, self.reason, self.check, self.origin))
class Warn(CheckResult):
# pylint: disable=too-few-public-methods