Skip to content

PYTHON-5314 Fix default imports #2300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
PYTHON-5314 Fix default imports
  • Loading branch information
ShaneHarvey committed Apr 21, 2025
commit 56338191e08991a0634208cc06f743447c0bb961
9 changes: 8 additions & 1 deletion pymongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@
from pymongo.write_concern import WriteConcern

# Public module compatibility imports
import pymongo.uri_parser # noqa: F401 # isort: skip
# isort: off
import pymongo.uri_parser # noqa: F401
import pymongo.change_stream # noqa: F401
import pymongo.client_session # noqa: F401
import pymongo.collection # noqa: F401
import pymongo.command_cursor # noqa: F401
import pymongo.database # noqa: F401
# isort: on

version = __version__
"""Current version of PyMongo."""
Expand Down
6 changes: 6 additions & 0 deletions test/test_default_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ def test_pymongo_submodule_attributes(self):
self.assertTrue(hasattr(pymongo, "uri_parser"))
self.assertTrue(pymongo.uri_parser)
self.assertTrue(pymongo.uri_parser.parse_uri)
self.assertTrue(pymongo.change_stream)
self.assertTrue(pymongo.client_session)
self.assertTrue(pymongo.collection)
self.assertTrue(pymongo.cursor)
self.assertTrue(pymongo.command_cursor)
self.assertTrue(pymongo.database)

def test_gridfs_imports(self):
import gridfs
Expand Down
Loading