I know that float("foo") could raise a ValueError, so I wrote my method as follows:
def cast_to_float(value: str) -> float:
try:
return float(value)
except ValueError as e:
# deal with it
However, I've just realized that float() can also raise an OverflowError. So I'm wondering whether there are other types of exceptions I am not catching. I understand that using except Exception is a bad practice.
How can I find all the exception types that float() can raise?
I have tried the docs as well as the “Go to Definition” menu of my IDE, but I can't find where the exceptions are raised.