6 ms·
okay, so use type annotations and mypy --strict
by batbomb 7y ago
okay, so use type annotations and mypy --strict
- CydeWeys 7y agoIt's not my project; I'm just a collaborator. My experience has been that a very tiny minority of Python code out there is written in this style, so unless you're only starting projects from scratch, you can't benefit from it.
- batbomb 7y agoyou can gradually type (probably don't use --strict in that case). It might not be a ton of benefit if you aren't actually writing new code though. There's a good document on this: https://mypy.readthedocs.io/en/latest/existing_code.html https://mypy.readthedocs.io/en/latest/existing_code.html
- CydeWeys 7y agoAnd that'd be fine if everyone were on board with it and that were the general direction of the project, but I don't think that's true. I've never seen a strict, type-annotated Python project out there in the wild, and I've seen a decent amount of them. A random non-primary-contributor isn't going to have much luck stepping into an established project and getting everyone to go along with adding annotations to the whole thing. And if I were starting a project from scratch, rather than coercing the language to do something it wasn't really designed for, I'd just use a language that has first-class support for types directly in the compiler, like Java or Go.
- totalperspectiv 7y agoBut at that point why not get something for they time you spend adding types and just use a different language?