On Fri, Jun 2, 2017 at 1:07 PM, Koos Zevenhoven <k7hoven at gmail.com> wrote: > [...] > I suppose it is, especially because there seems to be nothing that > prevents you from getting runtime annotations in the enclosing class/module > : > > > number: int > > @call > def number(): > return 42 > Well mypy actually gives an error for that, "Name 'number' already defined". > > But for functions one could have ( > using > the context manager example): > > > def session(url: str) -> ContextManager[DatabaseSession]: ... > > @predeclared > @contextmanager > def session(url: str) -> Iterator[DatabaseSession]: > s = DatabaseSession(url) > try: > yield s > finally: > s.close() > > > 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. > I'm not excited about that. -- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170602/8f983606/attachment.html>
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