You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately, the folks at MongoDB have issues disabled on the PyMongo GitHub Repository so I don't have a good way to get their insight into whether this is something they want to handle internally or not.
As such, I went ahead and created stubs for all of the modules in PyMongo for my own personal use. However, I'm sure there are some rough edges that would need smoothing before sending it out into the world.
I'd be more than happy to make a pull request for this, but wanted to follow the protocol before doing anything rash.
Thanks for working on this! We still would like to get permission from the project first before adding stubs to typeshed. From their README (https://github.com/mongodb/mongo-python-driver#support--feedback), it sounds like you should try the mongodb-user email list.
As far as I understand, they've been adding a similar feature to their roadmap for the official Node.js driver (using Typescript typings) so it could be a good time to ask.
@julien-c I created an issue in jira (Stub Files for PyMongo) that got some response from developers. It looks like there is desire to keep it within the pymongo project, but they are open to outside help.
I'm not really sure on that one either. I have used both approaches, and I personally prefer stub files. This is more based on keeping the actual code less verbose, but there is a verbosity/documentation trade off involved.
One thing that seems reasonable to consider when deciding which approach to use would be the regularity with which code changes and the time investment it would take to update .pyi files as opposed to type hints in the code. I can't really speak to that for their situation, but it might be something work bringing up to them.
We are closing all third-party stub requests issues without recent activity. We still welcome pull requests that add these to typeshed, although distributing the stubs with the the third-party package itself is preferable.
I'd like to provide an update as this project was recently completed by the PyMongo team and we've released stubs as a separate package in: pymongo-stubs.
pymongo-stubs' source code is hosted on GitHub (mongodb-labs/pymongo-stubs). The initial release is compatible with PyMongo >=3.11,<4.0 and Python >=3.6.
Our longer term plan is to get feedback on the type hints and later (in PyMongo 4.0) incorporate them directly into the codebase as inline type annotations (in PYTHON-2432). For now you are welcome to try out the stubs like this:
Activity
JelleZijlstra commentedon Nov 30, 2017
Thanks for working on this! We still would like to get permission from the project first before adding stubs to typeshed. From their README (https://github.com/mongodb/mongo-python-driver#support--feedback), it sounds like you should try the mongodb-user email list.
julien-c commentedon Dec 26, 2017
As far as I understand, they've been adding a similar feature to their roadmap for the official Node.js driver (using Typescript typings) so it could be a good time to ask.
GrierPhillips commentedon Dec 26, 2017
@julien-c I created an issue in jira (Stub Files for PyMongo) that got some response from developers. It looks like there is desire to keep it within the pymongo project, but they are open to outside help.
julien-c commentedon Dec 26, 2017
Upvoted and watched. Re. the discussion over there, isn't the simpler way to type-hint the actual code itself? (not sure about this)
GrierPhillips commentedon Dec 26, 2017
I'm not really sure on that one either. I have used both approaches, and I personally prefer stub files. This is more based on keeping the actual code less verbose, but there is a verbosity/documentation trade off involved.
One thing that seems reasonable to consider when deciding which approach to use would be the regularity with which code changes and the time investment it would take to update .pyi files as opposed to type hints in the code. I can't really speak to that for their situation, but it might be something work bringing up to them.
srittau commentedon Aug 26, 2020
We are closing all third-party stub requests issues without recent activity. We still welcome pull requests that add these to typeshed, although distributing the stubs with the the third-party package itself is preferable.
ShaneHarvey commentedon Dec 1, 2020
I'd like to provide an update as this project was recently completed by the PyMongo team and we've released stubs as a separate package in: pymongo-stubs.
pymongo-stubs' source code is hosted on GitHub (mongodb-labs/pymongo-stubs). The initial release is compatible with PyMongo >=3.11,<4.0 and Python >=3.6.
Our longer term plan is to get feedback on the type hints and later (in PyMongo 4.0) incorporate them directly into the codebase as inline type annotations (in PYTHON-2432). For now you are welcome to try out the stubs like this:
Or simply install pymongo-stubs to get a better IDE experience:

terencehonles commentedon Jun 30, 2021
I'm glad I bumped into this @ShaneHarvey. I didn't realize these have existed for awhile 😅