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

Guido van Rossum guido at python.org
Thu Aug 14 00:05:53 CEST 2014


On Wed, Aug 13, 2014 at 1:53 PM, Donald Stufft <donald at stufft.io> wrote:

> I agree with Alex that I think leaving the actual semantics of what these
> things
> mean up to a third party, which can possibly be swapped out by individual
> end
> users, is terribly confusing. I don’t think I agree though that this is a
> bad
> idea in general, I think that we should just add it for real and skip the
> indirection.
>

Yeah, I probably overstated the option of alternative interpretations. I
just don't want to have to write a PEP that specifies every little detail
of mypy's type checking algorithm, and I don't think anyone would want to
have to read such a PEP either. But maybe we can compromise on something
that sketches broad strokes and leaves the details up to the team that
maintains mypy (after all that tactic has worked pretty well for Python
itself :-).


> IOW I'm not sure I see the benefit of defining the syntax but not the
> semantics
> when it seems this is already completely possible given the fact that mypy
> exists.
>
> The only real benefits I can see from doing it are that the stdlib can use
> it,
> and the ``import typing`` aspect. I don't believe that the stdlib benefits
> are
> great enough to get the possible confusion of multiple different
> implementations
> and I think that the typing import could easily be provided as a project
> on PyPI
> that people can depend on if they want to use this in their code.
>
> So my vote would be to add mypy semantics to the language itself.
>

What exactly would that mean? I don't think the Python interpreter should
reject programs that fail the type check -- in fact, separating the type
check from run time is the most crucial point of my proposal.

I'm fine to have a discussion on things like covariance vs. contravariance,
or what form of duck typing are acceptable, etc.

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


More information about the Python-ideas mailing list