-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
AsyncContextManager is not callable error when used as decorator #6625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On Python 3.10+ AsyncContextManager implements __call__ so it can be used as a context manager Fixes #11783
I realised that this should probably be fixed in the python/typeshed repo first, so I submitted a PR there to fix this. |
@JelleZijlstra Looks like I was mistaken, it's in place here: https://github.com/python/typeshed/blob/master/stdlib/contextlib.pyi#L60-L61 |
But I guess it might have something to do with the inheritance hierarchy in the stubs, because in cpython the return type of https://github.com/python/cpython/blob/main/Lib/contextlib.py#L189-L193 |
Bug Report
It apprears that mypy is not aware that starting with Python 3.10 async context managers created using
contextlib.asynccontextmanager
can be used as decorators.To Reproduce
The following is example code from the Python docs for
contextlib.asynccontextmanager
. Running mypy against it results in the error included below the code.Expected Behavior
The example code should type check without problems on Python 3.10+
Actual Behavior
Mypy complains that the context manager is not callable.
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: