There must be an @overload
on __add__
somewhere in pint
which unintentionally matches to datetime
. If two quantities are added, unit checkers artificially restrict allowable operations to those supported by datetime
.
from pint import UnitRegistry
U = UnitRegistry()
Q = U.Quantity
sum_of_units = Q(1,"in") + Q(2,"in")
other = sum_of_units / 2 # Type checker complains that we can't use "/"
Wrap any sums of quantities in another Quantity
call.
...
sum_of_units = Q(Q(1,"in") + Q(2,"in")) # <-- We wrapped our sum in another call to Q
other = sum_of_units / 2 # No more complaints