Skip to content

Commit cee6c5a

Browse files
committed
Make new APIS private
1 parent 9a27445 commit cee6c5a

File tree

8 files changed

+46
-46
lines changed

8 files changed

+46
-46
lines changed

pymongo/asynchronous/client_session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,17 +591,17 @@ def operation_time(self) -> Optional[Timestamp]:
591591
return self._operation_time
592592

593593
@property
594-
def implicit(self) -> bool:
594+
def _is_implicit(self) -> bool:
595595
"""Whether this session was implicitly created by the driver."""
596596
return self._implicit
597597

598598
@property
599-
def attached_to_cursor(self) -> bool:
599+
def _is_attached_to_cursor(self) -> bool:
600600
"""Whether this session is owned by a cursor."""
601601
return self._attached_to_cursor
602602

603-
@attached_to_cursor.setter
604-
def attached_to_cursor(self, value: bool) -> None:
603+
@_is_attached_to_cursor.setter
604+
def _is_attached_to_cursor(self, value: bool) -> None:
605605
self._attached_to_cursor = value
606606

607607
@property

pymongo/asynchronous/command_cursor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(
8080
self._timeout = self._collection.database.client.options.timeout
8181
self._session = session
8282
if self._session is not None:
83-
self._session.attached_to_cursor = True
83+
self._session._is_attached_to_cursor = True
8484
self._killed = self._id == 0
8585
self._comment = comment
8686
if self._killed:
@@ -197,7 +197,7 @@ def session(self) -> Optional[AsyncClientSession]:
197197
198198
.. versionadded:: 3.6
199199
"""
200-
if self._session and not self._session.implicit:
200+
if self._session and not self._session._is_implicit:
201201
return self._session
202202
return None
203203

@@ -220,8 +220,8 @@ def _die_no_lock(self) -> None:
220220
self._collection.database.client._cleanup_cursor_no_lock(
221221
cursor_id, address, self._sock_mgr, self._session
222222
)
223-
if self._session and self._session.implicit:
224-
self._session.attached_to_cursor = False
223+
if self._session and self._session._is_implicit:
224+
self._session._is_attached_to_cursor = False
225225
self._session = None
226226
self._sock_mgr = None
227227

@@ -234,14 +234,14 @@ async def _die_lock(self) -> None:
234234
self._sock_mgr,
235235
self._session,
236236
)
237-
if self._session and self._session.implicit:
238-
self._session.attached_to_cursor = False
237+
if self._session and self._session._is_implicit:
238+
self._session._is_attached_to_cursor = False
239239
self._session = None
240240
self._sock_mgr = None
241241

242242
def _end_session(self) -> None:
243-
if self._session and self._session.implicit and not self._session.leave_alive:
244-
self._session.attached_to_cursor = False
243+
if self._session and self._session._is_implicit and not self._session.leave_alive:
244+
self._session._is_attached_to_cursor = False
245245
self._session._end_implicit_session()
246246
self._session = None
247247

pymongo/asynchronous/cursor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def __init__(
138138

139139
if session:
140140
self._session = session
141-
self._session.attached_to_cursor = True
141+
self._session._is_attached_to_cursor = True
142142
else:
143143
self._session = None
144144

@@ -149,7 +149,7 @@ def __init__(
149149
if not isinstance(limit, int):
150150
raise TypeError(f"limit must be an instance of int, not {type(limit)}")
151151
validate_boolean("no_cursor_timeout", no_cursor_timeout)
152-
if no_cursor_timeout and self._session and self._session.implicit:
152+
if no_cursor_timeout and self._session and self._session._is_implicit:
153153
warnings.warn(
154154
"use an explicit session with no_cursor_timeout=True "
155155
"otherwise the cursor may still timeout after "
@@ -282,7 +282,7 @@ def clone(self) -> AsyncCursor[_DocumentType]:
282282
def _clone(self, deepcopy: bool = True, base: Optional[AsyncCursor] = None) -> AsyncCursor: # type: ignore[type-arg]
283283
"""Internal clone helper."""
284284
if not base:
285-
if self._session and not self._session.implicit:
285+
if self._session and not self._session._is_implicit:
286286
base = self._clone_base(self._session)
287287
else:
288288
base = self._clone_base(None)
@@ -944,7 +944,7 @@ def session(self) -> Optional[AsyncClientSession]:
944944
945945
.. versionadded:: 3.6
946946
"""
947-
if self._session and not self._session.implicit:
947+
if self._session and not self._session._is_implicit:
948948
return self._session
949949
return None
950950

@@ -1035,8 +1035,8 @@ def _die_no_lock(self) -> None:
10351035
self._collection.database.client._cleanup_cursor_no_lock(
10361036
cursor_id, address, self._sock_mgr, self._session
10371037
)
1038-
if self._session and self._session.implicit:
1039-
self._session.attached_to_cursor = False
1038+
if self._session and self._session._is_implicit:
1039+
self._session._is_attached_to_cursor = False
10401040
self._session = None
10411041
self._sock_mgr = None
10421042

@@ -1055,8 +1055,8 @@ async def _die_lock(self) -> None:
10551055
self._sock_mgr,
10561056
self._session,
10571057
)
1058-
if self._session and self._session.implicit:
1059-
self._session.attached_to_cursor = False
1058+
if self._session and self._session._is_implicit:
1059+
self._session._is_attached_to_cursor = False
10601060
self._session = None
10611061
self._sock_mgr = None
10621062

pymongo/asynchronous/mongo_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ def _cleanup_cursor_no_lock(
21062106
# The cursor will be closed later in a different session.
21072107
if cursor_id or conn_mgr:
21082108
self._close_cursor_soon(cursor_id, address, conn_mgr)
2109-
if session and session.implicit and not session.leave_alive:
2109+
if session and session._is_implicit and not session.leave_alive:
21102110
session._end_implicit_session()
21112111

21122112
async def _cleanup_cursor_lock(
@@ -2138,7 +2138,7 @@ async def _cleanup_cursor_lock(
21382138
await self._close_cursor_now(cursor_id, address, session=session, conn_mgr=conn_mgr)
21392139
if conn_mgr:
21402140
await conn_mgr.close()
2141-
if session and session.implicit and not session.leave_alive:
2141+
if session and session._is_implicit and not session.leave_alive:
21422142
session._end_implicit_session()
21432143

21442144
async def _close_cursor_now(
@@ -2289,7 +2289,7 @@ async def _tmp_session(
22892289
raise
22902290
finally:
22912291
# Call end_session when we exit this scope.
2292-
if not s.attached_to_cursor:
2292+
if not s._is_attached_to_cursor:
22932293
await s.end_session()
22942294
else:
22952295
yield None

pymongo/synchronous/client_session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,17 +590,17 @@ def operation_time(self) -> Optional[Timestamp]:
590590
return self._operation_time
591591

592592
@property
593-
def implicit(self) -> bool:
593+
def _is_implicit(self) -> bool:
594594
"""Whether this session was implicitly created by the driver."""
595595
return self._implicit
596596

597597
@property
598-
def attached_to_cursor(self) -> bool:
598+
def _is_attached_to_cursor(self) -> bool:
599599
"""Whether this session is owned by a cursor."""
600600
return self._attached_to_cursor
601601

602-
@attached_to_cursor.setter
603-
def attached_to_cursor(self, value: bool) -> None:
602+
@_is_attached_to_cursor.setter
603+
def _is_attached_to_cursor(self, value: bool) -> None:
604604
self._attached_to_cursor = value
605605

606606
@property

pymongo/synchronous/command_cursor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(
8080
self._timeout = self._collection.database.client.options.timeout
8181
self._session = session
8282
if self._session is not None:
83-
self._session.attached_to_cursor = True
83+
self._session._is_attached_to_cursor = True
8484
self._killed = self._id == 0
8585
self._comment = comment
8686
if self._killed:
@@ -197,7 +197,7 @@ def session(self) -> Optional[ClientSession]:
197197
198198
.. versionadded:: 3.6
199199
"""
200-
if self._session and not self._session.implicit:
200+
if self._session and not self._session._is_implicit:
201201
return self._session
202202
return None
203203

@@ -220,8 +220,8 @@ def _die_no_lock(self) -> None:
220220
self._collection.database.client._cleanup_cursor_no_lock(
221221
cursor_id, address, self._sock_mgr, self._session
222222
)
223-
if self._session and self._session.implicit:
224-
self._session.attached_to_cursor = False
223+
if self._session and self._session._is_implicit:
224+
self._session._is_attached_to_cursor = False
225225
self._session = None
226226
self._sock_mgr = None
227227

@@ -234,14 +234,14 @@ def _die_lock(self) -> None:
234234
self._sock_mgr,
235235
self._session,
236236
)
237-
if self._session and self._session.implicit:
238-
self._session.attached_to_cursor = False
237+
if self._session and self._session._is_implicit:
238+
self._session._is_attached_to_cursor = False
239239
self._session = None
240240
self._sock_mgr = None
241241

242242
def _end_session(self) -> None:
243-
if self._session and self._session.implicit and not self._session.leave_alive:
244-
self._session.attached_to_cursor = False
243+
if self._session and self._session._is_implicit and not self._session.leave_alive:
244+
self._session._is_attached_to_cursor = False
245245
self._session._end_implicit_session()
246246
self._session = None
247247

pymongo/synchronous/cursor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def __init__(
138138

139139
if session:
140140
self._session = session
141-
self._session.attached_to_cursor = True
141+
self._session._is_attached_to_cursor = True
142142
else:
143143
self._session = None
144144

@@ -149,7 +149,7 @@ def __init__(
149149
if not isinstance(limit, int):
150150
raise TypeError(f"limit must be an instance of int, not {type(limit)}")
151151
validate_boolean("no_cursor_timeout", no_cursor_timeout)
152-
if no_cursor_timeout and self._session and self._session.implicit:
152+
if no_cursor_timeout and self._session and self._session._is_implicit:
153153
warnings.warn(
154154
"use an explicit session with no_cursor_timeout=True "
155155
"otherwise the cursor may still timeout after "
@@ -282,7 +282,7 @@ def clone(self) -> Cursor[_DocumentType]:
282282
def _clone(self, deepcopy: bool = True, base: Optional[Cursor] = None) -> Cursor: # type: ignore[type-arg]
283283
"""Internal clone helper."""
284284
if not base:
285-
if self._session and not self._session.implicit:
285+
if self._session and not self._session._is_implicit:
286286
base = self._clone_base(self._session)
287287
else:
288288
base = self._clone_base(None)
@@ -942,7 +942,7 @@ def session(self) -> Optional[ClientSession]:
942942
943943
.. versionadded:: 3.6
944944
"""
945-
if self._session and not self._session.implicit:
945+
if self._session and not self._session._is_implicit:
946946
return self._session
947947
return None
948948

@@ -1033,8 +1033,8 @@ def _die_no_lock(self) -> None:
10331033
self._collection.database.client._cleanup_cursor_no_lock(
10341034
cursor_id, address, self._sock_mgr, self._session
10351035
)
1036-
if self._session and self._session.implicit:
1037-
self._session.attached_to_cursor = False
1036+
if self._session and self._session._is_implicit:
1037+
self._session._is_attached_to_cursor = False
10381038
self._session = None
10391039
self._sock_mgr = None
10401040

@@ -1053,8 +1053,8 @@ def _die_lock(self) -> None:
10531053
self._sock_mgr,
10541054
self._session,
10551055
)
1056-
if self._session and self._session.implicit:
1057-
self._session.attached_to_cursor = False
1056+
if self._session and self._session._is_implicit:
1057+
self._session._is_attached_to_cursor = False
10581058
self._session = None
10591059
self._sock_mgr = None
10601060

pymongo/synchronous/mongo_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ def _cleanup_cursor_no_lock(
21022102
# The cursor will be closed later in a different session.
21032103
if cursor_id or conn_mgr:
21042104
self._close_cursor_soon(cursor_id, address, conn_mgr)
2105-
if session and session.implicit and not session.leave_alive:
2105+
if session and session._is_implicit and not session.leave_alive:
21062106
session._end_implicit_session()
21072107

21082108
def _cleanup_cursor_lock(
@@ -2134,7 +2134,7 @@ def _cleanup_cursor_lock(
21342134
self._close_cursor_now(cursor_id, address, session=session, conn_mgr=conn_mgr)
21352135
if conn_mgr:
21362136
conn_mgr.close()
2137-
if session and session.implicit and not session.leave_alive:
2137+
if session and session._is_implicit and not session.leave_alive:
21382138
session._end_implicit_session()
21392139

21402140
def _close_cursor_now(
@@ -2285,7 +2285,7 @@ def _tmp_session(
22852285
raise
22862286
finally:
22872287
# Call end_session when we exit this scope.
2288-
if not s.attached_to_cursor:
2288+
if not s._is_attached_to_cursor:
22892289
s.end_session()
22902290
else:
22912291
yield None

0 commit comments

Comments
 (0)