[Python-ideas] Proposal: Use mypy syntax for function annotations

Todd toddrjen at gmail.com
Thu Aug 14 00:28:15 CEST 2014


On Aug 13, 2014 9:45 PM, "Guido van Rossum" <guido at python.org> wrote:
> (1) A change of direction for function annotations
>
> PEP 3107, which introduced function annotations, is intentional
non-committal about how function annotations should be used. It lists a
number of use cases, including but not limited to type checking. It also
mentions some rejected proposals that would have standardized either a
syntax for indicating types and/or a way for multiple frameworks to attach
different annotations to the same function. AFAIK in practice there is
little use of function annotations in mainstream code, and I propose a
conscious change of course here by stating that annotations should be used
to indicate types and to propose a standard notation for them.
>
> (We may have to have some backwards compatibility provision to avoid
breaking code that currently uses annotations for some other purpose.
Fortunately the only issue, at least initially, will be that when running
mypy to type check such code it will produce complaints about the
annotations; it will not affect how such code is executed by the Python
interpreter. Nevertheless, it would be good to deprecate such alternative
uses of annotations.)

I watched the original talk and read your proposal.  I think type
annotations could very very useful in certain contexts.

However, I still don't get this bit. Why would allowing type annotations
automatically imply that no other annotations would be possible?  Couldn't
we formalize what would be considered a type annotation while still
allowing annotations that don't fit this criteria to be used for other
things?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140814/a9d6d6fb/attachment.html>


More information about the Python-ideas mailing list