3 ms·
[Edited: some of the Mypy maintainers, e.g. Guido van Rossum and Ivan Levkivskyi are on the Python core team, not all of them.] > This is adding to the total t
by j88439h84 7y ago
[Edited: some of the Mypy maintainers, e.g. Guido van Rossum and Ivan Levkivskyi are on the Python core team, not all of them.]
> This is adding to the total test-writing workload of the user, instead of a statically typed language where you just get all of this for "free".
Yeah it does require executing the code. Python has a strong test-coverage culture. Do people not run tests much in more-static languages?
> This does appear to require an additional external dependency though
`typing.Protocol` is in Python 3.8.
- yawaramin 7y ago> Do people not run tests much in more-static languages? Sure we do :-) but most projects would be lucky to reach something like 70% test coverage. You can't derive 100% type coverage from that. You can get 100% type coverage with a good typechecker.
- munk-a 7y agoAlso, PHP has a nice approach here, type declaration errors can (essentially) be run-time file parse errors depending on your settings, so even if there aren't tests covering everything, if the coverage is decent enough to hit every file (I'll roughly throw out ~40% if it's a mature code base) then you're probably safe.
- DonaldPShimoda 7y ago> some of the Mypy maintainers Ah, fair enough. Still, I hadn't realized that! > Do people not run tests much in more-static languages? You do, but the tests you need are different. You don't need to test that all inputs are valid by type (checking for runtime type errors in Python, for example), because type correctness is guaranteed when you compile. So instead, you just have to write tests for functionality. In a dynamically typed language, you need both to really ensure you're covered. (Or else you're just relying on invariants that people obey, which is... risky.) > `typing.Protocol` is in Python 3.8. Ah! Excellent. Glad to hear it! I will certainly be making use of that haha.