Skip to content

Commit 2900718

Browse files
committed
address comments
1 parent 5466484 commit 2900718

File tree

5 files changed

+38
-40
lines changed

5 files changed

+38
-40
lines changed

pymongo/asynchronous/mongo_client.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,20 +1234,14 @@ def eq_props(self) -> tuple[tuple[_Address, ...], Optional[str], Optional[str],
12341234

12351235
def __eq__(self, other: Any) -> bool:
12361236
if isinstance(other, self.__class__):
1237-
if self._topology is None:
1238-
return self.eq_props() == other.eq_props()
1239-
else:
1240-
return self._topology == other._topology
1237+
return self.eq_props() == other.eq_props()
12411238
return NotImplemented
12421239

12431240
def __ne__(self, other: Any) -> bool:
12441241
return not self == other
12451242

12461243
def __hash__(self) -> int:
1247-
if self._topology is None:
1248-
return hash(self.eq_props())
1249-
else:
1250-
return hash(self._topology)
1244+
return hash(self.eq_props())
12511245

12521246
def _repr_helper(self) -> str:
12531247
def option_repr(option: str, value: Any) -> str:
@@ -1264,7 +1258,7 @@ def option_repr(option: str, value: Any) -> str:
12641258

12651259
# Host first...
12661260
if self._topology is None:
1267-
options = ["host={self._host}", "port={self._port}"]
1261+
options = self._resolve_srv_info["seeds"]
12681262
else:
12691263
options = [
12701264
"host=%r"

pymongo/asynchronous/uri_parser.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Copyright 2011-present MongoDB, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you
4+
# may not use this file except in compliance with the License. You
5+
# may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12+
# implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
15+
16+
"""Tools to parse and validate a MongoDB URI."""
117
from __future__ import annotations
218

319
from typing import Any, Optional

pymongo/srv_resolver.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

pymongo/synchronous/mongo_client.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,20 +1232,14 @@ def eq_props(self) -> tuple[tuple[_Address, ...], Optional[str], Optional[str],
12321232

12331233
def __eq__(self, other: Any) -> bool:
12341234
if isinstance(other, self.__class__):
1235-
if self._topology is None:
1236-
return self.eq_props() == other.eq_props()
1237-
else:
1238-
return self._topology == other._topology
1235+
return self.eq_props() == other.eq_props()
12391236
return NotImplemented
12401237

12411238
def __ne__(self, other: Any) -> bool:
12421239
return not self == other
12431240

12441241
def __hash__(self) -> int:
1245-
if self._topology is None:
1246-
return hash(self.eq_props())
1247-
else:
1248-
return hash(self._topology)
1242+
return hash(self.eq_props())
12491243

12501244
def _repr_helper(self) -> str:
12511245
def option_repr(option: str, value: Any) -> str:
@@ -1262,7 +1256,7 @@ def option_repr(option: str, value: Any) -> str:
12621256

12631257
# Host first...
12641258
if self._topology is None:
1265-
options = ["host={self._host}", "port={self._port}"]
1259+
options = self._resolve_srv_info["seeds"]
12661260
else:
12671261
options = [
12681262
"host=%r"

pymongo/synchronous/uri_parser.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Copyright 2011-present MongoDB, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you
4+
# may not use this file except in compliance with the License. You
5+
# may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12+
# implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
15+
16+
"""Tools to parse and validate a MongoDB URI."""
117
from __future__ import annotations
218

319
from typing import Any, Optional

0 commit comments

Comments
 (0)