Showing content from http://mail.python.org/pipermail/python-dev/attachments/20170602/8f983606/attachment.html below:
<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>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4