mongo-python-driver - PR #2591: Loosen `AsyncClientSession.with_transaction` callback type

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Duplicate
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 🔵 Done
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      lpulley has created PR #2591: Loosen `AsyncClientSession.with_transaction` callback type in mongo-python-driver

      Issue Text:

        1. 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`.

        1. 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]]`.

        1. Testing Plan

      Type-checking should cover this change.

        1. Checklist
          <!-- Do not delete the items provided on this checklist. -->
          1. Checklist for Author
      • [ ] 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?
          1. 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?

            Assignee:
            Shane Harvey
            Reporter:
            TPM Jira Automations Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: