2 ms·
I gave a presentation on type annotations at the EuroPython 2017 where I also investigated empirically how many open-source Python projects really use type chec
by ThePhysicist 6y ago
I gave a presentation on type annotations at the EuroPython 2017 where I also investigated empirically how many open-source Python projects really use type checking, I present the results at the end (33 minutes in):
https://www.youtube.com/watch?v=vM2Zoy4Sxhk&t=2181s https://www.youtube.com/watch?v=vM2Zoy4Sxhk&t=2181s
My conclusion was that only a small fraction of projects really used them, there were a lot of projects that had type checks in their code but only in "homeopathic" doses. I started using them for some of my Python projects as well (e.g https://github.com/algoneer/algoneer https://github.com/algoneer/algoneer) and while I find them useful I think they're not as useful as a "real" type system in a fully typed language like Golang. Still, they're very useful for discovering simple mistakes that would only show up in unit testing otherwise.
You can also "misuse" them for other purposes, at the end of the presentation I e.g. show how you can implement software contracts with them. Of course this would wreck a type checker like mypy, so don't do that in your codebase. That's probably also one of my critiques as the annotation syntax can in principle be used for anything, but mypy and other tools are not able to deal with code that does that.