[Python-ideas] PEP 484 evolution

Andrew Barnert abarnert at yahoo.com
Sat Mar 19 23:12:08 EDT 2016


On Mar 19, 2016, at 18:34, Rick Johnson <rantingrickjohnson at gmail.com> wrote:
> 
> On Saturday, March 19, 2016 at 5:43:12 PM UTC-5, Terry Reedy wrote:
> > Just to be sure you know, one of the options is to put
> > type-hints in a separate stub file, so only those
> > concerned will ever see them.  
> 
> Yes, I was aware of the "stubfile option", and had stubfiles
> been the *ONLY* option, i would have thrown my support
> behind this type-hints thing 110%!

That would definitely turn me off the feature.

In practice, I've found that, at least for me, the largest benefit of PEP 484 has come from documenting interfaces. There are a reasonable fraction of cases where a name and type for each parameter is enough to understand the use of a function, but a name alone isn't. Of course there are other cases where the types get in the way--so I just don't specify them there.

This shouldn't be too surprising--ML, Haskell, etc. users have long known that sometimes it aids readability to explicitly declare a type even when the inference engine makes it unnecessary. Why should it be any different when dynamic typing always makes it unnecessary?

Anyway, if stub files were the only way to specify types, PEP 484 would probably still be useful for some people, as in Dropbox's project, but it would be a lot less interesting to me.



More information about the Python-ideas mailing list