-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Unknown
-
Affects Version/s: None
-
Component/s: Infrastructure
-
None
-
Python Drivers
-
None
-
None
-
None
-
None
-
None
-
None
User opened a pull request with the following:
Context
AsyncClientSession.with_transaction's callback is typed as Callable[[AsyncClientSession], Coroutine[Any, Any, _T]] but does not use any of Coroutine's interface that isn't already provided in its parent, Awaitable.
In other words: at runtime, any function that returns an Awaitable works as callback, but callback's type unnecessarily requires that the function's return type matches Coroutine.
The type should be changed from Callable[[AsyncClientSession], Coroutine[Any, Any, _T]] to Callable[[AsyncClientSession], Awaitable[_T]] so that a non-Coroutine Awaitable can be used as callback.
Definition of done
Change the type of AsyncClientSession.with_transaction's callback argument from Callable[[AsyncClientSession], Coroutine[Any, Any, _T]] to Callable[[AsyncClientSession], Awaitable[_T]].
Pitfalls
What should the implementer watch out for? What are the risks?