[Python-ideas] Proposal: Use mypy syntax for function annotations

Antoine Pitrou antoine at python.org
Thu Aug 21 15:23:39 CEST 2014


Le 20/08/2014 23:28, Jim Baker a écrit :
>
> Mypy’s approach to parameterizing types using slice
> notation/|__getitem__| is a rather neat hack, given how it does not
> require any new notation, matches rather similar syntax in languages
> like Scala and Haskell, and can be readily added to existing types,
> whether builtins like |list|, collections like |deque|, or ABC
> collection types like |Iterator| and|Sequence|. Adding such
> parameterization support to builtin/stdlib types is a compelling reason
> for including in 3.5. An enthusiastic +1!

I'm -1 on using __getitem__ for parametering types. It is indeed a hack 
and its limitations will bite us harshly when wanting to refine the type 
descriptions (for example to describe a constraint on a collection's size).

> One last thing: let’s not add |List|, |TList|, etc. Just use |list| and
> other existing types to generate new types.

I'm -1 on that, for exactly the same reason as above.

Regards

Antoine.




More information about the Python-ideas mailing list