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

Antoine Pitrou antoine at python.org
Sun Aug 24 01:00:54 CEST 2014


Le 23/08/2014 13:25, Steven D'Aprano a écrit :
>>
>> It's not a new use. A type class is a class, and calling it is just
>> instantiating that class. There's nothing new here. If you think that's
>> a bit "meta", it's no different than e.g. higher-order functions.
>
> There's no instantiation during *static* analysis, because the code
> hasn't run yet.

In your idea of "static analysis", it hasn't. Because you think it 
should involve some kind of separate syntax analysis tool that has 
nothing to do with regular Python. But Python is powerful enough to let 
you do that using normal introspection of modules.

And it's *exactly* how we are exposing function annotations (and also 
docstrings, etc.): using runtime-accessible introspection information 
which is gathered by importing modules and therefore actually 
*executing* toplevel module code. Not merely compiling it.

The rest of your message I'm not motivated to respond to, sorry.

Regards

Antoine.




More information about the Python-ideas mailing list