Linux: Boottime API: Refactor __sub__ to operate through __add__() and negate() for improved clarity and reuse

This commit is contained in:
Gustavo Moreira
2024-10-30 15:39:40 +11:00
parent 7abe92cf2f
commit e197fbaf5f
@@ -2236,17 +2236,9 @@ class Timespec64Abstract(abc.ABC):
if not isinstance(other, Timespec64Abstract):
raise TypeError("Requires an object subclass of Timespec64Abstract")
# pylint: disable=E1101
result = Timespec64Concrete(
tv_sec=self.tv_sec - other.tv_sec,
tv_nsec=self.tv_nsec - other.tv_nsec,
)
result.normalize()
return self + other.negate()
def negate(self):
def negate(self) -> "Timespec64Concrete":
"""Returns a new Timespec64Concrete object with the values of the current object negated"""
# pylint: disable=E1101
result = Timespec64Concrete(