In a big library, I had a ‘bug’ because a function which accept only float but not int
def foo(penalty: float):
if not isinstance(penalty, float):
raise ValueError(f"`penalty` has to be a float, but is {penalty}")
# some instruction
I would like to open a PR with the following :
def foo(penalty: float):
if not isinstance(penalty, (int,float)):
raise ValueError(f"`penalty` has to be a float or int, but is {penalty}")
# some instruction
but before this, I ask myself :
are there good reason, in Python to accept float but not int ?