[Python-ideas] Proposal: Use mypy syntax for function annotations
Greg Ewing
greg.ewing at canterbury.ac.nz
Sun Aug 24 07:54:22 CEST 2014
Steven D'Aprano wrote:
> I don't really understand what you're trying to say here, so I may be
> misinterpreting you. I *think* that you're trying to say that for every
> type in the standard library, and every class created by third parties
> (including subclasses), the author will have to "declare" (in some
> unknown sense) that it can be used for type annotations like MyList[T],
> for some type T.
I suppose the run-time incarnations of the type descriptions
could be looser, but if you want to use them for static checking,
the static checker is going to have to know what MyList[T] means
in some detail (what effect the parameter has on the method
types, etc.) The programmer will have to specify all that
somehow.
The way this is done in other languages with static type
checking is to give the class declaration a parameter list.
I was envisaging that the mypy type description syntax would have
something equivalent. Not sure what form it would take, though.
--
Greg
More information about the Python-ideas
mailing list