From c88190a7b40db81406822abf08b3b9583ba090a2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 9 Mar 2025 16:37:18 +0000 Subject: [PATCH 1/2] add dunder methods --- src/quantity_api/__init__.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/quantity_api/__init__.py b/src/quantity_api/__init__.py index 9d4b56a..f2d8aed 100644 --- a/src/quantity_api/__init__.py +++ b/src/quantity_api/__init__.py @@ -17,5 +17,26 @@ def value(self) -> V: ... def unit(self) -> U: ... ### Dunder Methods - def __eq__[B](self, other: Self[op.CanEq[V, B], U], /) -> B: ... + def __ne__[B](self, other: Self[op.CanEq[V, B], U], /) -> B: ... + def __lt__[B](self, other: Self[op.CanOrd[V, B], U], /) -> B: ... + def __le__[B](self, other: Self[op.CanOrd[V, B], U], /) -> B: ... + def __gt__[B](self, other: Self[op.CanOrd[V, B], U], /) -> B: ... + def __ge__[B](self, other: Self[op.CanOrd[V, B], U], /) -> B: ... + + def __pos__(self) -> Self[op.CanPos[V], U]: ... + def __neg__(self) -> Self[op.CanNeg[V], U]: ... + def __abs__(self) -> Self[op.CanAbs[V], U]: ... + + def __add__[B](self, other: Self[op.CanAdd[V, B], U], /) -> Self[op.CanAdd[V, B], U]: ... + def __radd__[B](self, other: Self[op.CanAdd[V, B], U], /) -> Self[op.CanAdd[V, B], U]: ... + def __sub__[B](self, other: Self[op.CanSub[V, B], U], /) -> Self[op.CanSub[V, B], U]: ... + def __rsub__[B](self, other: Self[op.CanSub[V, B], U], /) -> Self[op.CanSub[V, B], U]: ... + + def __mul__[B](self, other: Self[op.CanMul[V, B], U], /) -> Self[op.CanMul[V, B], U]: ... + def __rmul__[B](self, other: Self[op.CanMul[V, B], U], /) -> Self[op.CanMul[V, B], U]: ... + def __truediv__[B](self, other: Self[op.CanDiv[V, B], U], /) -> Self[op.CanDiv[V, B], U]: ... + def __rtruediv__[B](self, other: Self[op.CanDiv[V, B], U], /) -> Self[op.CanDiv[V, B], U]: ... + + def __pow__(self, other: int | Self[op.CanPow[V], U], /) -> Self[op.CanPow[V], U]: ... + def __rpow__(self, other: int | Self[op.CanPow[V], U], /) -> Self[op.CanPow[V], U]: ... From 8b95039961a30ea3a02f7c2ce1fe99b03b631362 Mon Sep 17 00:00:00 2001 From: andrewgsavage Date: Sun, 9 Mar 2025 19:29:08 +0000 Subject: [PATCH 2/2] Update src/quantity_api/__init__.py Co-authored-by: Nathaniel Starkman --- src/quantity_api/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/quantity_api/__init__.py b/src/quantity_api/__init__.py index f2d8aed..fb782d6 100644 --- a/src/quantity_api/__init__.py +++ b/src/quantity_api/__init__.py @@ -18,11 +18,11 @@ def unit(self) -> U: ... ### Dunder Methods def __eq__[B](self, other: Self[op.CanEq[V, B], U], /) -> B: ... - def __ne__[B](self, other: Self[op.CanEq[V, B], U], /) -> B: ... - def __lt__[B](self, other: Self[op.CanOrd[V, B], U], /) -> B: ... - def __le__[B](self, other: Self[op.CanOrd[V, B], U], /) -> B: ... - def __gt__[B](self, other: Self[op.CanOrd[V, B], U], /) -> B: ... - def __ge__[B](self, other: Self[op.CanOrd[V, B], U], /) -> B: ... + def __ne__[B](self, other: Self[op.CanNe[V, B], U], /) -> B: ... + def __lt__[B](self, other: Self[op.CanLt[V, B], U], /) -> B: ... + def __le__[B](self, other: Self[op.CanLe[V, B], U], /) -> B: ... + def __gt__[B](self, other: Self[op.CanGt[V, B], U], /) -> B: ... + def __ge__[B](self, other: Self[op.CanGe[V, B], U], /) -> B: ... def __pos__(self) -> Self[op.CanPos[V], U]: ... def __neg__(self) -> Self[op.CanNeg[V], U]: ...