[Python-ideas] PEP 484 (Type Hints) -- first draft round

Guido van Rossum guido at python.org
Thu Jan 22 01:50:16 CET 2015


On Wed, Jan 21, 2015 at 4:04 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
wrote:

> On 01/22/2015 11:30 AM, Guido van Rossum wrote:
>
>> But the static checker is like a linter and it's common to run those
>> infrequently (e.g. only when submitting a diff for review) while running
>> unittests frequently (e.g. whenever the developer has written some new
>> code).
>> Assuming you have fast unittests.
>>
>
> This still doesn't make sense to me. If your unit tests are any
> good, they'll contain tests that use the types you're supposed to
> be importing, so they'll fail if you forget to import them.
>

Not necessarily. I've seen plenty of code that takes instances a certain
class as argument and calls methods of that type but never constructs a new
instance nor does any of the other things for which you need the class
name, and where the module defining the class is never imported. Such code
works fine, but when you want to declare the type you have to import it.


>  And, having coded up much of a possible typing.py module already
>> (https://github.com/ambv/typehinting/tree/master/prototyping) I really
>> don't
>> see the big problem with run-time evaluation of constraints.
>>
>
> Well, having to quote forward-referenced types is a fairly big
> aesthetic problem for me, even if it's not a practical one. To
> my mind it's a worse syntactic hack than '::' would be. But it
> seems you're not bothered by it so much.


You can write a lot of code without ever having to use a forward reference.
But "::" would have to be used everywhere.

Or perhaps I value the ability to use this with Python 3.4 more than you do.

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


More information about the Python-ideas mailing list