[issue30359] Annotating a function as returning an (async) context manager?

2017-06-07 Thread Nick Coghlan
Nick Coghlan added the comment: As far as whether or not this usage fits within the guidelines at https://www.python.org/dev/peps/pep-0008/#function-annotations, it would definitely be worth bringing up in a python-dev thread before going ahead with it. I think it's a good dynamic use of

[issue30359] Annotating a function as returning an (async) context manager?

2017-06-07 Thread Nick Coghlan
Nick Coghlan added the comment: Even Python 2 functions support setting arbitrary attributes, so contextlib2.contextmanager can always just add an __annotations__ dict to decorated functions if it doesn't already exist. ``` >>> def f(): ... pass ... >>> f.__annotations__ Traceback (most

[issue30359] Annotating a function as returning an (async) context manager?

2017-06-07 Thread Nathaniel Smith
Nathaniel Smith added the comment: I can think of two downsides to using __annotations__ for this: 1) Obviously contextlib itself isn't going to add any kind of annotation in any versions before 3.7, but third-party projects might (like contextlib2, say). And these projects have been known to

[issue30359] Annotating a function as returning an (async) context manager?

2017-05-20 Thread Jelle Zijlstra
Changes by Jelle Zijlstra : -- nosy: +Jelle Zijlstra ___ Python tracker ___ ___

[issue30359] Annotating a function as returning an (async) context manager?

2017-05-19 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- title: A standard convention for annotating a function as returning an (async) context manager? -> Annotating a function as returning an (async) context manager? ___ Python tracker