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

Bob Ippolito bob at redivi.com
Fri Aug 22 16:30:36 CEST 2014


On Friday, August 22, 2014, Skip Montanaro <skip at pobox.com> wrote:

> There's been a lot to read in this and related threads over the past nine
> days. (According to Gmail. It qualitatively seems much longer to me.) I
> think I've followed along reasonably well. Forgive me if I missed the
> answers to these questions. The proposal on the table is to adopt MyPy's
> type annotations for Python 3.mumble. I presume MyPy already supports them.
>
> 1. Can MyPy be used today as a standalone static type checker for Python
> 3.x code without actually compiling anything? That is, can I just sprinkle
> type annotations into my code and run a front-end pass of MyPy much the
> same way I'd run pylint, vulture, flake8, or other lint-ish program?
>

Yes. mypy -S performs checking without execution.

2. Assuming the answer to #1 is "yes," if you start sprinkling type
> annotations into your code and running "mypy *.py", will it tell you when
> it needs a missing type annotation to more fully check things, or will it
> silently process code without annotations and not let you know that it's
> not really checking much?
>

No. It happily and silently accepts dynamic code with no annotations. It
can't do much for you with that code, but it doesn't complain.

3. Will we get into a phase like the early days of "const" in ANSI C where
> addition of "const" in one location in your existing code base forced you
> into a never-ending iterations of adding const all over the place? I forget
> what that was called ("const propagation"?), but I recall that it generally
> wasn't a fun activity.
>

Nope.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140822/21f85fce/attachment.html>


More information about the Python-ideas mailing list