I want python to raise an exception if the argument type does not match the parameter type. Function example:
def add_integers (a: int, b:int) -> int:
return a + b
What that function will return with different arguments
add_integers(1,2) = 3
add_integers(True,2) = 3
add_integers("1",2) = Exception (because it cannot add str and int)
I want to make sure that the function does not except an argument of type boolean and ONLY integers. I know I can make an if statement to check the type and raise an exception myself or maybe use a decorator function , but I was wondering if there is a simpler way of doing it?
TypeErrorwhich is raised?