Loading kodo/quantities/__init__.py +6 −0 Original line number Diff line number Diff line Loading @@ -226,6 +226,12 @@ if TYPE_CHECKING: # The remainder of a floor division with another quantity def __mod__(self, other: Quantity[U], /) -> Quantity[U]: ... # Quantities can be compared for order and equality def __lt__(self, other: Quantity[U], /) -> bool: ... def __le__(self, other: Quantity[U], /) -> bool: ... def __gt__(self, other: Quantity[U], /) -> bool: ... def __ge__(self, other: Quantity[U], /) -> bool: ... else: # Although the runtime implementation does not use TypeVars, it is still generic to # allow type subscripting. Loading test.py +17 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,18 @@ def test_modulus() -> None: assert (3600 @ Time.MS) % Time.S == 600 @ Time.MS def test_order() -> None: assert (1 @ Time.S) > (999 @ Time.MS) assert (1 @ Time.S) >= (999 @ Time.MS) assert (1 @ Time.S) >= (1 @ Time.S) assert (999 @ Time.MS) < (1 @ Time.S) assert (999 @ Time.MS) <= (1 @ Time.S) assert (1 @ Time.S) <= (1 @ Time.S) assert (1 @ Time.S) != (2 @ Time.S) if TYPE_CHECKING: def type_checks() -> None: # Checks for type checker false negatives Loading @@ -55,3 +67,8 @@ if TYPE_CHECKING: _ = (1 @ Time.S) // 2 # type: ignore[operator] _ = (1 @ Time.S) // 2.0 # type: ignore[operator] _ = (1 @ Time.S) > 10 # type: ignore[operator] _ = (1 @ Time.S) >= 10 # type: ignore[operator] _ = (1 @ Time.S) < 10 # type: ignore[operator] _ = (1 @ Time.S) <= 10 # type: ignore[operator] Loading
kodo/quantities/__init__.py +6 −0 Original line number Diff line number Diff line Loading @@ -226,6 +226,12 @@ if TYPE_CHECKING: # The remainder of a floor division with another quantity def __mod__(self, other: Quantity[U], /) -> Quantity[U]: ... # Quantities can be compared for order and equality def __lt__(self, other: Quantity[U], /) -> bool: ... def __le__(self, other: Quantity[U], /) -> bool: ... def __gt__(self, other: Quantity[U], /) -> bool: ... def __ge__(self, other: Quantity[U], /) -> bool: ... else: # Although the runtime implementation does not use TypeVars, it is still generic to # allow type subscripting. Loading
test.py +17 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,18 @@ def test_modulus() -> None: assert (3600 @ Time.MS) % Time.S == 600 @ Time.MS def test_order() -> None: assert (1 @ Time.S) > (999 @ Time.MS) assert (1 @ Time.S) >= (999 @ Time.MS) assert (1 @ Time.S) >= (1 @ Time.S) assert (999 @ Time.MS) < (1 @ Time.S) assert (999 @ Time.MS) <= (1 @ Time.S) assert (1 @ Time.S) <= (1 @ Time.S) assert (1 @ Time.S) != (2 @ Time.S) if TYPE_CHECKING: def type_checks() -> None: # Checks for type checker false negatives Loading @@ -55,3 +67,8 @@ if TYPE_CHECKING: _ = (1 @ Time.S) // 2 # type: ignore[operator] _ = (1 @ Time.S) // 2.0 # type: ignore[operator] _ = (1 @ Time.S) > 10 # type: ignore[operator] _ = (1 @ Time.S) >= 10 # type: ignore[operator] _ = (1 @ Time.S) < 10 # type: ignore[operator] _ = (1 @ Time.S) <= 10 # type: ignore[operator]