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

Steven D'Aprano steve at pearwood.info
Thu Aug 14 19:35:19 CEST 2014


On Thu, Aug 14, 2014 at 06:34:43PM +0200, Manuel Cerón wrote:
> On Thu, Aug 14, 2014 at 4:27 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> >
> > My main concern with static typing is that it tends to be
> > anti-duck-typing, while I consider duck-typing to be a major *feature* of
> > Python.  The example in the page above is "def fib(n: int):". Fib should
> > get an count (non-negative integer) value, but it need not be an int, and
> > 'half' the ints do not qualify. Reading the tutorial, I could not tell if
> > it supports numbers.Number (which should approximate the domain from above.)
> 
> 
> This is a good point. But I think that static typing and duck typing are
> not mutually exclusive.
[...]
> Are there any plans for adding something like this to mypy?

The mypy FAQs claim to be focusing on nominative typing, but haven't 
ruled out structural typing in the future:

http://www.mypy-lang.org/faq.html



-- 
Steven


More information about the Python-ideas mailing list