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

Remove Generic Typing from the ClientSession Class

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Unknown
    • Resolution: Fixed
    • None
    • 4.2
    • None
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: