This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: @asynccontextmanager decorated functions are not callable like @contextmanager
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fried, graingert, lukasz.langa, serhiy.storchaka, yselivanov
Priority: normal Keywords: patch

Created on 2019-10-08 20:45 by fried, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16667 merged fried, 2019-10-08 20:57
PR 30233 merged graingert, 2021-12-23 00:55
Messages (5)
msg354232 - (view) Author: Jason Fried (fried) * Date: 2019-10-08 20:45
The standard contextmanager decorator produces a wrapper that itself can be used as a decorator

```
@contextmanager
def some_context():
    ...
    yield

@some_context()
def some_function():
    # we are inside a with some_context() now. 
    ...


```

When I created a version of asynccontextmanager internally before it was available in the  stdLib I copied this behavior and I have people internally to facebook using this behavior,  Was there a reason this behavior was not replicated to asynccontextmanager?  

I have a diff an tests to add
msg402528 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-23 21:36
New changeset 86b833badd3d6864868404ead2f8c7994d24f85c by Jason Fried in branch 'main':
bpo-38415: Allow using @asynccontextmanager-made ctx managers as decorators (GH-16667)
https://github.com/python/cpython/commit/86b833badd3d6864868404ead2f8c7994d24f85c
msg402529 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-23 21:37
Look, not even 23 months to land this thing!

Thanks, Jason! ✨ 🍰 ✨
msg409056 - (view) Author: Thomas Grainger (graingert) * Date: 2021-12-23 00:57
actually it was already done in 13 months!
msg414094 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2022-02-26 12:05
New changeset b57dbe5d1be925b99f16fe5893e339f92fc05888 by Thomas Grainger in branch 'main':
bpo-38415: Remove redundant AsyncContextDecorator.__call__ override from _AsyncGeneratorContextManager (GH-30233)
https://github.com/python/cpython/commit/b57dbe5d1be925b99f16fe5893e339f92fc05888
History
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82596
2022-02-26 12:05:50serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg414094
2021-12-23 00:57:23graingertsetmessages: + msg409056
2021-12-23 00:55:34graingertsetnosy: + graingert

pull_requests: + pull_request28454
2021-09-23 21:37:12lukasz.langasetstatus: open -> closed
versions: + Python 3.11, - Python 3.7, Python 3.8, Python 3.9
messages: + msg402529

resolution: fixed
stage: patch review -> resolved
2021-09-23 21:36:10lukasz.langasetnosy: + lukasz.langa
messages: + msg402528
2019-10-08 20:57:33friedsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16250
2019-10-08 20:45:49friedcreate