3 ms·
Have you tried Python's type hints with Mypy, and so you have any thoughts on it?
by nkantar 10y ago
Have you tried Python's type hints with Mypy, and so you have any thoughts on it?
- sevensor 10y agoI haven't yet -- type annotations in Python 3 still don't seem to have stabilized. Although I admit I haven't looked too deeply into it, I know a bunch of new stuff landed in 3.6. The appeal of a library that adds a functional layer on top of Python is that it partitions "new stuff" from "old stuff". It seems easier to tear out and reimplement if we screw it up, versus type annotations diffusing out into the rest of our codebase.
- chubot 10y agoFWIW I tried it on a relatively new 10K line project and gave up, because it doesn't play well with metaprogramming. I consider metaprogramming to be part of Python, so mypy and statically typed Python are really different languages with less power IMO. And of course the mypy author knew that -- that's why he gave it a different name. http://www.oilshell.org/blog/2016/11/30.html http://www.oilshell.org/blog/2016/11/30.html update here: http://www.oilshell.org/blog/2017/01/06.html http://www.oilshell.org/blog/2017/01/06.html I'm not claiming my experience generalizes... if you have a lot of Java-like code you can probably use mypy. Bizarrely, some people do actually have a lot of Java-like Python code.
- domenukk 10y agoI've used typehints to write a compiler but with my own small homegrown annotations and it worked really well. It feels natural coming from languages with similar syntax like rust and the like. Cool integrates well with pycharm too