[Python-ideas] Python-ideas Digest, Vol 93, Issue 31
Raymond Hettinger
raymond.hettinger at gmail.com
Thu Aug 14 02:59:28 CEST 2014
On Aug 13, 2014, at 2:09 PM, Guido van Rossum <guido at python.org> wrote:
>> The goal is to make it possible to add
>> type checking annotations to 3rd party modules (and even to the stdlib)
>> while allowing unaltered execution of the program by the (unmodified)
>> Python 3.5 interpreter.
>
> Is the goal to "make it possible" or would it quickly become required
> (i.e. any time you write normal, readable Python, it would break
> someone's optimizer, refactorer, linter, etc.?)
>
> Whoa, whoa. That's not at all the idea. Currently *nobody* uses type annotations because there's no standard notation. My goal is to enable their use by proposing a standard, nothing more.
> ...
> Mypy lets you create stub modules that shadow stdlib (and other) modules during typechecking, and it comes with a modest set of standard stubs for some of the most popular stdlib modules. In most cases it's actually much more effective to create a stub than to add the annotations to the stdlib source code -- the stdlib code itself often is difficult to type check due to various optimizations or backwards compatibility concerns, but writing stubs is relatively straightforward, and the stubs will give useful guidance to users of the stdlib who care to run mypy over their own code.
+1 from me :-)
In the PEP, please make it clear that you don't want any
overly enthusiastic coredevs injecting the annotations into
the standard library (have no doubt, some one would do it)
and demanding changes to existing APIs where annotations didn't
fit neatly (like Larry's proposal to change the long-standing APIs
to use his nullable ints by adding None to optional int signatures).
Raymond
P.S. I would really like for the annotations to grow some way
to communicate exceptions as well as return types (i.e. that
list.index can raise a ValueError and list.pop can raise an IndexError).
This would be only for the exceptions directly added by a function or method,
not ones raised by the data (which is something the function can't control).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140813/d6ad64e4/attachment.html>
More information about the Python-ideas
mailing list