Update Distance comparison operators

remove order=True and implement the comparison operators manually to fix typing error
This commit is contained in:
RndName 2022-01-07 15:34:49 +01:00
parent 54745e786e
commit 795df1a93f
No known key found for this signature in database
GPG Key ID: 5EF516FD9537F7C0

View File

@ -26,7 +26,7 @@ INHG_TO_MMHG = 25.400002776728
LBS_TO_KG = 0.453592
@dataclass(frozen=True, order=True)
@dataclass(frozen=True)
class Distance:
distance_in_meters: float
@ -78,6 +78,18 @@ class Distance:
def __bool__(self) -> bool:
return not math.isclose(self.meters, 0.0)
def __lt__(self, other: Distance) -> bool:
return self.meters < other.meters
def __le__(self, other: Distance) -> bool:
return self.meters <= other.meters
def __gt__(self, other: Distance) -> bool:
return self.meters > other.meters
def __ge__(self, other: Distance) -> bool:
return self.meters >= other.meters
def feet(value: float) -> Distance:
return Distance.from_feet(value)