Skip to content
Merged
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
9 changes: 8 additions & 1 deletion pymongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@

from pymongo import _csot
from pymongo._version import __version__, get_version_string, version_tuple
from pymongo.asynchronous.mongo_client import AsyncMongoClient
from pymongo.common import MAX_SUPPORTED_WIRE_VERSION, MIN_SUPPORTED_WIRE_VERSION
from pymongo.cursor import CursorType
from pymongo.operations import (
Expand All @@ -105,6 +104,14 @@
from pymongo.synchronous.mongo_client import MongoClient
from pymongo.write_concern import WriteConcern

try:
from pymongo.asynchronous.mongo_client import AsyncMongoClient
except Exception as e:
# PYTHON-4781: Importing asyncio can fail on Windows.
import warnings

warnings.warn(f"Failed to import Async PyMongo: {e}", RuntimeWarning, stacklevel=2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should we use ImportWarning instead?

ImportWarning: Base category for warnings triggered during the process of importing a module (ignored by default).

  1. Suggest {e!r} to provide the repr which will include the exception class instead of just the message.

  2. Suggest import warnings as _warnings to avoid polluting the pymongo namespace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


version = __version__
"""Current version of PyMongo."""

Expand Down
Loading