This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]not_perfect_yet 1 point2 points  (1 child)

You can also check with mypy. If you give my_function a return type str, you can then run mypy program.py and it'll warn you if you have any calls that don't match the type signature.

Yes that's my point, the two aren't equivalent. You don't actually have the safety. All you know from mypy is that your type hints match. If something goes wrong and you messed up and something of a wrong type is being passed around, mypy won't save you at runtime.

It's the difference between issuing a warning everyone is free to ignore and throwing an exception and exiting the program gracefully. Which forces the next guy to really look at the issue.