[Python-ideas] PEP 484 (Type Hints) -- first draft round
Guido van Rossum
guido at python.org
Fri Jan 23 00:19:37 CET 2015
On Thu, Jan 22, 2015 at 1:45 PM, Ed Kellett <edk141 at gmail.com> wrote:
> On Thu Jan 22 2015 at 20:05:41 Guido van Rossum <guido at python.org> wrote:
>> This paragraph (and a some words you wrote earlier) feels really
>> offensive to me. I am doing the best I can. I have listened to an
>> *enormous* amount of feedback and if you read back earlier discussions
>> (going back to I believe September or October 2014) or skim the typehinting
>> issue tracker <https://github.com/ambv/typehinting/issues> you'll find
>> that I am taking the feedback very seriously.
> I'm sorry. I don't mean to minimize the work you've put into this, and in
> any case there was no call to speak so unconstructively.
> The only situation where there may be a desire to change something (the
>> minimal thing being to add a "# type: OFF" comment at the top of a module)
>> is when a library that uses annotations for non-type-hinting purposes is
>> used by an application (or another library) that wants to use type hints,
>> and the user who is running the type checker cannot live with the noise
>> output spewed by the type checker for that library.
> This is more or less the situation I imagined. Or, more problematic - the
> user running the type checker might assume the library is no good because
> it sets off the warnings.
Hopefully it'll be a while before users who are that clueless will figure
out how to run the type checker. :-)
> Finally. In the distant future there may be more agreement about the use
>> of annotations for type hints, and users will start asking library authors
>> to change their code. But that's no different than other evolution of the
>> language -- it won't happen overnight, you will get ample warning
>> (DeprecationWarning :-), and the principle of supply and demand will apply.
>> Heck, if you're not using Python 3, you're safe until 2020.
> I understand that it's a long way off, but in my view that'd be a
> regression: I know not many things are using annotations at the moment, but
> where they are used they fit really well (extra information for
> command-line-ifying a function being the one I have most experience with).
> It seems a shame to throw away something so neat when it feels as if the
> different use cases could coexist peacefully.
Yes, I am well aware that it's a regression. Regressions are taken
seriously; see e.g. PEP 4, which describes the deprecation process for
modules. It's much the same for language features. But that doesn't mean we
don't sometimes decide to change our mind. (And this isn't limited to major
version number transitions like Python 2 -> 3.)
This is one of those cases. I expect (or hope?) that at some point in the
distant future users who see an annotation will know that it is a type
hint, without having to figure out whether may be there is a decorator or
some other less-visible mechanism (e.g. a metaclass, shudder) that gives it
a different meaning. I believe that this is a more desirable future than
one in which type hints have to compete with other meta-information for
arguments for their syntactic position.
At the same time -- let me emphasize this one more time -- I hope there
will never be a time in the future where type hints are mandatory or
otherwise always expected to exist. (If you want that you should probably
switch to Java sooner rather than later. :-)
And lastly, such a future is a long way off, and in 3.5 your code won't
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas