CoinAmt: remove unneeded variadic params in dunder methods
This commit is contained in:
parent
23dcf58b7d
commit
474fc7ab96
1 changed files with 15 additions and 15 deletions
30
mmgen/amt.py
30
mmgen/amt.py
|
|
@ -125,53 +125,53 @@ class CoinAmt(Decimal, Hilite, InitErrors): # abstract class
|
|||
def __repr__(self):
|
||||
return "{}('{}')".format(type(self).__name__, self.__str__())
|
||||
|
||||
def __add__(self, other, *args, **kwargs):
|
||||
def __add__(self, other):
|
||||
"""
|
||||
we must allow other to be int(0) to use the sum() builtin
|
||||
"""
|
||||
if type(other) is type(self) or (other == 0 and isinstance(other, int)):
|
||||
return type(self)(Decimal.__add__(self, other, *args, **kwargs), from_decimal=True)
|
||||
return type(self)(Decimal.__add__(self, other), from_decimal=True)
|
||||
raise TypeError(
|
||||
f'operand {other} is of incorrect type ({type(other).__name__} != {type(self).__name__})')
|
||||
|
||||
__radd__ = __add__
|
||||
|
||||
def __sub__(self, other, *args, **kwargs):
|
||||
def __sub__(self, other):
|
||||
if type(other) is type(self):
|
||||
return type(self)(Decimal.__sub__(Decimal(self), Decimal(other), *args, **kwargs), from_decimal=True)
|
||||
return type(self)(Decimal.__sub__(Decimal(self), Decimal(other)), from_decimal=True)
|
||||
raise TypeError(
|
||||
f'operand {other} is of incorrect type ({type(other).__name__} != {type(self).__name__})')
|
||||
|
||||
def __rsub__(self, other, *args, **kwargs):
|
||||
def __rsub__(self, other):
|
||||
if type(other) is type(self):
|
||||
return type(self)(Decimal.__rsub__(self, other, *args, **kwargs), from_decimal=True)
|
||||
return type(self)(Decimal.__rsub__(self, other), from_decimal=True)
|
||||
raise TypeError(
|
||||
f'operand {other} is of incorrect type ({type(other).__name__} != {type(self).__name__})')
|
||||
|
||||
def __mul__(self, other, *args, **kwargs):
|
||||
def __mul__(self, other):
|
||||
return type(self)('{:0.{p}f}'.format(
|
||||
Decimal.__mul__(self, Decimal(other), *args, **kwargs),
|
||||
Decimal.__mul__(self, Decimal(other)),
|
||||
p = self.max_prec))
|
||||
|
||||
__rmul__ = __mul__
|
||||
|
||||
def __truediv__(self, other, *args, **kwargs):
|
||||
def __truediv__(self, other):
|
||||
return type(self)('{:0.{p}f}'.format(
|
||||
Decimal.__truediv__(self, Decimal(other), *args, **kwargs),
|
||||
Decimal.__truediv__(self, Decimal(other)),
|
||||
p = self.max_prec))
|
||||
|
||||
def __rtruediv__(self, other, *args, **kwargs):
|
||||
def __rtruediv__(self, other):
|
||||
return type(self)('{:0.{p}f}'.format(
|
||||
Decimal.__rtruediv__(self, Decimal(other), *args, **kwargs),
|
||||
Decimal.__rtruediv__(self, Decimal(other)),
|
||||
p = self.max_prec))
|
||||
|
||||
def __neg__(self, *args, **kwargs):
|
||||
def __neg__(self):
|
||||
self.method_not_implemented()
|
||||
|
||||
def __floordiv__(self, *args, **kwargs):
|
||||
def __floordiv__(self, other):
|
||||
self.method_not_implemented()
|
||||
|
||||
def __mod__(self, *args, **kwargs):
|
||||
def __mod__(self, other):
|
||||
self.method_not_implemented()
|
||||
|
||||
def is_coin_amt(proto, num, *, from_unit=None, from_decimal=False):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue