-
Type:
Task
-
Resolution: Duplicate
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
🔵 Done
-
None
-
None
-
None
-
None
-
None
-
None
lpulley has created PR #2591: Loosen `AsyncClientSession.with_transaction` callback type in mongo-python-driver
Issue Text:
-
- Summary
`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`.
-
- Changes in this PR
Changed the type of `AsyncClientSession.with_transaction`'s `callback` argument from `Callable[[AsyncClientSession], Coroutine[Any, Any, _T]]` to `Callable[[AsyncClientSession], Awaitable[_T]]`.
-
- Testing Plan
Type-checking should cover this change.
-
- Checklist
<!-- Do not delete the items provided on this checklist. -->- Checklist for Author
- Checklist
- [ ] Did you update the changelog (if necessary)?
- [ ] Is the intention of the code captured in relevant tests?
- [ ] If there are new TODOs, has a related JIRA ticket been created?
-
-
- Checklist for Reviewer {@primary_reviewer}
-
- [ ] Does the title of the PR reference a JIRA Ticket?
- [ ] Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
- [ ] Have you checked for spelling & grammar errors?
- [ ] Is all relevant documentation (README or docstring) updated?
- duplicates
-
PYTHON-5623 Loosen AsyncClientSession.with_transaction callback type
-
- Closed
-