<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 2, 2017 at 9:41 AM, Koos Zevenhoven <span dir="ltr"><<a href="mailto:k7hoven@gmail.com" target="_blank">k7hoven@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri, Jun 2, 2017 at 6:34 PM, Naomi Seyfer <<a href="mailto:naomi@seyfer.org">naomi@seyfer.org</a>> wrote:<br>
> Yep, interested in implementing it! I will put implementation time on my<br>
> schedule and tell y'all when it is, for holding myself accountable -- it<br>
> turns out I never do anything not on my schedule.<br>
<br>
</span>I still don't understand what would happen with __annotations__. If<br>
the decorator returns a non-function, one would expect the annotations<br>
to be in the __annotations__ attribute of the enclosing class or<br>
module. If it returns a function, they would be in the __annotations__<br>
attribute of the function. And I'm talking about the runtime behavior<br>
in Python as explained in PEP484 and PEP526. I would expect these<br>
declarations to behave according to the same principles as other ways<br>
to annotate variables/functions. If there is no runtime behavior, a<br>
comment-based syntax might be more appropriate. Or have I missed<br>
something?<br></blockquote></div><br></div><div class="gmail_extra">So when returning a function, the runtime version of the decorator can easily update the function's __annotations__. But when returning a non-function, the decorator would have a hard time updating __annotations__ of the containing class/module without "cheating" (e.g. sys._getframe()). I think the latter is similar to e.g. attributes defined with @property -- those don't end up in __annotations__ either. I think this is an acceptable deficiency.<br></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>