3 ms·
> Correctness in Python is all about unit tests - if you don't bother with them then you're playing with fire (and of course I often "play with fire"). But Pyt
by arinlen 5y ago
> Correctness in Python is all about unit tests - if you don't bother with them then you're playing with fire (and of course I often "play with fire").
But Python does support type hints, and tools like MyPy do use those type hints to evaluate correctness. It seems to me that Python's type hints are indeed Python's way to check for correctness.
Also, unit tests don't verify correctness. They only serve to check whatever small set of ad-hoc invariant developers put up.
- t43562 5y agoYou can have a program with correct type handling that doesn't work but with unit tests you have a program that works and documentation (in the form of the test) about the ways in which the programmer expected it to work. That's why I find type hinting to be relatively high effort for relatively low benefit and choose to use it only where I feel it makes life better. The optionality suits me. It's a nice to have but that's all.