-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
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.