Skip to content

Add __call__ to AsyncContextManager on Python 3.10+ #6624

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

Closed
wants to merge 1 commit into from

Conversation

ljodal
Copy link

@ljodal ljodal commented Dec 17, 2021

On Python 3.10+ AsyncContextManager implements call
so it can be used as a context manager on async functions.

On Python 3.10+ AsyncContextManager implements __call__
so it can be used as a context manager
@ljodal
Copy link
Author

ljodal commented Dec 17, 2021

Oops, seems like this is already in place

@ljodal ljodal closed this Dec 17, 2021
@ljodal ljodal deleted the patch-1 branch December 17, 2021 21:39
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

starlette (https://github.com/encode/starlette)
+ starlette/routing.py:549: error: Incompatible types in assignment (expression has type "_DefaultLifespan", variable has type "Callable[[Any], AsyncContextManager[Any]]")  [assignment]
+ starlette/routing.py:549: note: "_DefaultLifespan.__call__" has type "Callable[[Arg(object, 'app')], _DefaultLifespan]"

Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/dependencies/data.py:129: error: Incompatible return value type (got "Lock", expected "AsyncContextManager[Any]")
+ tanjun/dependencies/data.py:129: note: "Lock" is missing following "AsyncContextManager" protocol member:
+ tanjun/dependencies/data.py:129: note:     __call__

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant