<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 2, 2017 at 1:07 PM, 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"><div dir="ltr">[...]<span class=""><br></span>I suppose it is, especially because there seems to be nothing that prevents you from getting runtime annotations in the enclosing class/module<div style="font-family:monospace,monospace;display:inline">​:</div><br><br><font face="monospace, monospace">number: int<br><br>@call<br>def number():<br>    return 42</font><br></div></blockquote><div><br></div><div>Well mypy actually gives an error for that, "Name 'number' already defined".<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div>But for functions o<font face="arial, helvetica, sans-serif">ne could have (<div style="display:inline">​using</div> the </font>context manager example):<br><br><br><div><font face="monospace, monospace">def session(url: str) -> ContextManager[<wbr>DatabaseSession]: ...<br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">@predeclared<br>@contextmanager<br>def session(url: str) -> Iterator[DatabaseSession]:<br>    s = DatabaseSession(url)<br>    try:</font></div><div><font face="monospace, monospace">        yield s</font></div><div><font face="monospace, monospace">    finally:</font></div><div><font face="monospace, monospace">        s.close()</font><br><font face="arial, helvetica, sans-serif"><br></font><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">This makes it clear that the function is declared elsewhere. But the `predeclared` decorator would need tricks like sys._getframe(1) to set session.__annotations__ according to the predeclaration.</font></div></div></div></div></blockquote><div><br></div><div>I'm not excited about that. <br></div></div><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>