Update Distance comparison operators

remove order=True and implement the comparison operators manually to fix typing error

cherry-pick from 795df1a9
This commit is contained in:
RndName 2022-01-07 15:34:49 +01:00
parent f63fae2d4f
commit 57ee611d06
No known key found for this signature in database
GPG Key ID: 5EF516FD9537F7C0

View File

@ -21,7 +21,7 @@ INHG_TO_HPA = 33.86389
INHG_TO_MMHG = 25.400002776728
@dataclass(frozen=True, order=True)
@dataclass(frozen=True)
class Distance:
distance_in_meters: float
@ -73,6 +73,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)