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

Cem Karan cfkaran2 at gmail.com
Tue Aug 26 04:12:05 CEST 2014


On Aug 25, 2014, at 7:03 AM, Chris Angelico <rosuav at gmail.com> wrote:

> On Mon, Aug 25, 2014 at 8:57 PM, Cem Karan <cfkaran2 at gmail.com> wrote:
>> from type_checker import TYPE_CHECKER
>> 
>> def foo(a: {TYPE_CHECKER: int}):
>>        pass
> 
> I still don't think this offers much benefit over
> 
> def foo(a: int):
>    pass
> 
> It's a lot wordier and the flexibility will almost never be needed. So
> is that multiplexing really worth it?

I'm just trying to preserve annotations as they currently are; that is, without a clearly defined meaning.  Right now, I see annotations as a great place to store both documentation and type information, but without some kind of multiplexing standard you can't have both at the same time.  I also suspect that if some kind of standard is in place that allows multiplexing, then other uses will be invented to take advantage of it.  

The other alternative is to define more attributes that functions are supposed to have, but that feels like a hack.  It feels cleaner to me to store information about the arguments and return values with the arguments and return values directly, rather than somewhere else.  I know that with decorators that isn't a problem, but it doesn't feel as clean to me.

Thanks,
Cem Karan


More information about the Python-ideas mailing list