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

Guido van Rossum guido at python.org
Mon Aug 25 05:12:07 CEST 2014


On Sun, Aug 24, 2014 at 7:51 PM, Antoine Pitrou <antoine at python.org> wrote:

>
> Le 24/08/2014 22:30, Guido van Rossum a écrit :
>
>  People who are talking about what should happen if a decorator changes
>> __annotations__ are likewise missing the point.
>>
>
> But you shouldn't use annotations for something that refuses to use
> runtime introspection abilities. There's no reason to waste annotations if
> the need can be fullfilled by separate description files in a DSL that
> doesn't even need to be Python code (but cutely looks like so).
>

It doesn't feel like a waste to me -- having it syntactically be part of
the source code to me is a strong advantage over stubs or special comments
or even special syntax in docstrings.

As I have said several times now, it fulfills exactly the original (pre-PEP
3107) goal I had in mind for them.


> And it's not surprising that some people may be missing the point when a
> feature pretends to use a runtime facility but interprets it from a
> separate channel which eschews any code execution.
>

There is no pretense here. It is simply useful to make the type annotations
*also* available at run time.


> Your proposal seems determined by the fact that mypy has much grander
> ambitions (and therefore requires its insertion into regular Python), but
> it doesn't make use of that power at all, worse, it forbids others to use
> it.
>

This remark about mypy's ambitions sounds delusional and paranoid. I
wouldn't care about mypy at all if it wasn't right in line with my
intentions and desires for Python. And while its author *originally*
intended to create a whole new language (since that is what academics do
:-), he gracefully changed his design (over a year ago) when I suggested
that it might be more useful if it fit neatly into Python 3 annotations.

Finally, I would actually be okay if we found a way to let type hints and
other annotations coexist -- I just prefer type hints to be the default
use, since I see them as much more generally useful than all other uses
combined.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140824/8d08ea01/attachment.html>


More information about the Python-ideas mailing list