Skip to content

Commit 99a5c8a

Browse files
committed
Address review
1 parent afd82f4 commit 99a5c8a

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

pymongo/asynchronous/mongo_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
cast,
6060
)
6161

62-
import pymongo.uri_parser_shared
6362
from bson.codec_options import DEFAULT_CODEC_OPTIONS, CodecOptions, TypeRegistry
6463
from bson.timestamp import Timestamp
6564
from pymongo import _csot, common, helpers_shared, periodic_executor
@@ -121,6 +120,7 @@
121120
_handle_option_deprecations,
122121
_handle_security_options,
123122
_normalize_options,
123+
_validate_uri,
124124
split_hosts,
125125
)
126126
from pymongo.write_concern import DEFAULT_WRITE_CONCERN, WriteConcern
@@ -786,7 +786,7 @@ def __init__(
786786
# it must be a URI,
787787
# https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
788788
if "/" in entity:
789-
res = pymongo.uri_parser_shared._validate_uri(
789+
res = _validate_uri(
790790
entity,
791791
port,
792792
validate=True,

pymongo/asynchronous/srv_resolver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ async def _resolve(*args: Any, **kwargs: Any) -> resolver.Answer:
6161
if hasattr(asyncresolver, "resolve"):
6262
# dnspython >= 2
6363
return await asyncresolver.resolve(*args, **kwargs) # type:ignore[return-value]
64-
raise ConfigurationError("Upgrade to dnspython version >= 2.0")
64+
raise ConfigurationError(
65+
"Upgrade to dnspython version >= 2.0 to use AsyncMongoClient with mongodb+srv:// connections."
66+
)
6567

6668

6769
_INVALID_HOST_MSG = (

pymongo/synchronous/mongo_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
cast,
5959
)
6060

61-
import pymongo.uri_parser_shared
6261
from bson.codec_options import DEFAULT_CODEC_OPTIONS, CodecOptions, TypeRegistry
6362
from bson.timestamp import Timestamp
6463
from pymongo import _csot, common, helpers_shared, periodic_executor
@@ -120,6 +119,7 @@
120119
_handle_option_deprecations,
121120
_handle_security_options,
122121
_normalize_options,
122+
_validate_uri,
123123
split_hosts,
124124
)
125125
from pymongo.write_concern import DEFAULT_WRITE_CONCERN, WriteConcern
@@ -784,7 +784,7 @@ def __init__(
784784
# it must be a URI,
785785
# https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
786786
if "/" in entity:
787-
res = pymongo.uri_parser_shared._validate_uri(
787+
res = _validate_uri(
788788
entity,
789789
port,
790790
validate=True,

pymongo/synchronous/srv_resolver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def _resolve(*args: Any, **kwargs: Any) -> resolver.Answer:
6161
if hasattr(asyncresolver, "resolve"):
6262
# dnspython >= 2
6363
return asyncresolver.resolve(*args, **kwargs) # type:ignore[return-value]
64-
raise ConfigurationError("Upgrade to dnspython version >= 2.0")
64+
raise ConfigurationError(
65+
"Upgrade to dnspython version >= 2.0 to use MongoClient with mongodb+srv:// connections."
66+
)
6567

6668

6769
_INVALID_HOST_MSG = (

test/test_default_exports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def test_bson(self):
6969

7070
def test_pymongo_imports(self):
7171
import pymongo
72-
from pymongo.asynchronous.uri_parser import parse_uri
7372
from pymongo.auth import MECHANISMS
7473
from pymongo.auth_oidc import (
7574
OIDCCallback,
@@ -199,9 +198,10 @@ def test_pymongo_imports(self):
199198
from pymongo.server_api import ServerApi, ServerApiVersion
200199
from pymongo.server_description import ServerDescription
201200
from pymongo.topology_description import TopologyDescription
202-
from pymongo.uri_parser_shared import (
201+
from pymongo.uri_parser import (
203202
parse_host,
204203
parse_ipv6_literal_host,
204+
parse_uri,
205205
parse_userinfo,
206206
split_hosts,
207207
split_options,

0 commit comments

Comments
 (0)