nominaldelta

nominal difference of date/datetime
git clone https://git.ce9e.org/nominaldelta.git

commit
8354eb612c411991fdc6a9546645bf469c9001ca
parent
1df8e6badf52a9e971b235c2da6cc30cc4f04f01
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-08-31 08:46
fix some type annotations

Diffstat

M nominaldelta.py 10 +++++-----

1 files changed, 5 insertions, 5 deletions


diff --git a/nominaldelta.py b/nominaldelta.py

@@ -97,10 +97,10 @@ class NominalDelta:
   97    97     def __hash__(self):
   98    98         return hash((self.months, self.days, self.seconds))
   99    99 
  100    -1     def __bool__(self):
   -1   100     def __bool__(self) -> bool:
  101   101         return bool(self.months or self.days or self.seconds)
  102   102 
  103    -1     def __eq__(self, other: Self) -> Self:
   -1   103     def __eq__(self, other) -> bool:
  104   104         if isinstance(other, NominalDelta):
  105   105             return (
  106   106                 self.months == other.months
@@ -109,7 +109,7 @@ class NominalDelta:
  109   109             )
  110   110         return NotImplemented
  111   111 
  112    -1     def __add__(self: Self, other: Self) -> Self:
   -1   112     def __add__(self: Self, other) -> Self:
  113   113         if isinstance(other, NominalDelta):
  114   114             return self.__class__(
  115   115                 months=self.months + other.months,
@@ -118,7 +118,7 @@ class NominalDelta:
  118   118             )
  119   119         return NotImplemented
  120   120 
  121    -1     def __sub__(self: Self, other: Self) -> Self:
   -1   121     def __sub__(self: Self, other) -> Self:
  122   122         if isinstance(other, NominalDelta):
  123   123             return self.__class__(
  124   124                 months=self.months - other.months,
@@ -153,7 +153,7 @@ class NominalDelta:
  153   153         return (-self).__radd__(other)
  154   154 
  155   155     @classmethod
  156    -1     def diff(cls, a: date, b: date):
   -1   156     def diff(cls: type[Self], a: date, b: date) -> Self:
  157   157         if isinstance(a, datetime) and isinstance(b, datetime):
  158   158             return dt_diff(a, b)
  159   159         elif isinstance(a, date) and isinstance(b, date):