<p dir="ltr">When discussed on reddit programming ("proggit" as its called), there were plenty of people saying they really didn't like the mypy syntax:</p>
<p dir="ltr"><a href="http://www.reddit.com/r/programming/comments/2disob/proposal_for_python_type_annotations_from_guido/">http://www.reddit.com/r/programming/comments/2disob/proposal_for_python_type_annotations_from_guido/</a><br>
</p>
<p dir="ltr">(Declaration: I am the author of obiwan <a href="https://pypi.python.org/pypi/obiwan">https://pypi.python.org/pypi/obiwan</a> and I got a lot of upvotes on that proggit thread when I promoted the obiwan style instead)</p>
<div class="gmail_quote">On 14 Aug 2014 13:16, "<a href="mailto:willvarfar@gmail.com">willvarfar@gmail.com</a>" <<a href="mailto:willvarfar@gmail.com">willvarfar@gmail.com</a>> wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I fully support formalizing Python 3's annotations for type checking.<br>
<br>
I wrote - and use daily - my own type checker called obiwan<br>
<a href="https://pypi.python.org/pypi/obiwan" target="_blank">https://pypi.python.org/pypi/obiwan</a><br>
<br>
Its a runtime type checker, and if enabled will check and enforce<br>
types on every call.<br>
<br>
I support the wider adoption and standardization of static type<br>
checkers, but runtime checkers are still wanted for very dynamic code<br>
and for checking external data e.g. I use obiwan for validating JSON.<br>
<br>
One small detail is that I feel the obiwan annotations are more<br>
pythonic than the mypy examples given.<br>
<br>
E.g. instead of:<br>
<br>
from typing import List, Dict<br>
<br>
def word_count(input: List[str]) -> Dict[str, int]:<br>
...<br>
<br>
It would be:<br>
<br>
def word_count(input: [str]) -> {str, int}:<br>
...<br>
<br>
Obiwan does not check types within functions; I was unwilling to try<br>
and overload comments! You can invoke obiwan to check things<br>
explicitly, but these are more as assertions.<br>
<br>
Anyway, when I look at the mypy in-function annotations (where<br>
comments are overloaded) I am cautious. It would be far nicer if we<br>
had annotations as part of the language instead, e.g. instead of:<br>
<br>
result = {} #type: Dict[str, int]<br>
<br>
It would be:<br>
<br>
result = {} -> {str, int}<br>
<br>
where we use the -> arrow again. I can see pros and cons for any<br>
implementation (as we'd want the annotation to be both to declare a<br>
type and to check a type, and want the annotation to be attached to<br>
the variable forever etc) so this would need a full PEP treatment and<br>
possibly be configurable as asserts are.<br>
<br>
But proper annotation support in the language rather than overloading<br>
comments would definitely be my preference.<br>
<br>
/Will<br>
<br>
/Will<br>
</blockquote></div>