[Python-Dev] Type hints -- a mediocre programmer's reaction

Barry Warsaw barry at python.org
Tue Apr 21 15:48:59 CEST 2015


On Apr 21, 2015, at 01:34 PM, Steven D'Aprano wrote:

>Putting the type information in a stub file is an exponentially more distant
>fourth best, or to put it another way, *the worst* solution for where to put
>type hints. Not only do you Repeat Yourself with the name of the parameter,
>but also the name of the function (or method and class) AND module. The type
>information *isn't even in the same file*, which increases the chance of it
>being lost, forgotten, deleted, out of date, unmaintained, etc.

All true, but the trade-off is the agility and ease of working on, reading,
and understanding the stdlib, all of which IMHO will suffer if type hints are
inlined there.

What I don't want to have happen is for type hints to slowly infiltrate the
stdlib to the point where no patch will be accepted unless it also has hints.
I have the same gut reaction to this as RDM expressed a few posts back.

One of the thing I love most about Python is its dynamic typing.  I'm all for
giving linter developers a hook for experimenting with their tools, I just
don't care and I don't want to *have* to care.  Maybe some day they will make
it so compelling that I will care, but I want to be convinced first.

So I think stub files in the stdlib are the right compromise today.

Cheers,
-Barry


More information about the Python-Dev mailing list