Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-3283

Remove Generic Typing from the ClientSession Class

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.2
    • Affects Version/s: None
    • Component/s: None
    • None

      As reported in https://www.mongodb.com/community/forums/t/most-operations-have-session-type-unknown-with-pyright-pylance/165662, the typing for the ClientSession object is awkward due to the documented limitation of https://github.com/python/mypy/issues/3737. Additionally, because it appears in public method signatures, it can prevent strict typing because it is typed as unknown unless a concrete session object is passed in.

      We looked at how ClientSession is typically used and decided it is not worth having it be generic given the trouble it is causing. The downside is that the ClientSession.client property will lose generic typing, but that property is not typically used because you typically have a handle to the original client object.

      Because this is an API change we will not backport to 4.1.

            Assignee:
            steve.silvester@mongodb.com Steve Silvester
            Reporter:
            steve.silvester@mongodb.com Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: