3 ms·
Agreed, one cannot just expect this to be known. Does type annotations in Python actually catch type errors? I thought they were mainly for documentation.
by DNF2 4y ago
Agreed, one cannot just expect this to be known.
Does type annotations in Python actually catch type errors? I thought they were mainly for documentation.
- snicker7 4y agoYes, if you use tooling (mypy). It definitely helped me a few times.
- nickm12 4y agoAbsolutely yes, but you have to use a typechecker like mypy (and generally make it part of your release builds). I've found typechecking my Python code makes my development iterations much faster than writing tests. My biggest issue is that if you are using a legacy codebase or 3P library without type annotations then the "Any" type become pervasive and removes much of the value you get from type annotations. You can run mypy in a mode that flags when this is happening, but it's not like you're going to go type annotate the world just to push your code change.