Skip to content

Commit f0ab015

Browse files
committed
PYTHON-4324 Fix typing bugs and typos
1 parent 2a394e7 commit f0ab015

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

Diff for: pymongo/asynchronous/network.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ async def command(
140140
# Support CSOT
141141
applied_csot = False
142142
if client:
143-
applied_csot = conn.apply_timeout(client, spec)
143+
res = conn.apply_timeout(client, spec)
144+
applied_csot = bool(res)
144145
_csot.apply_write_concern(spec, write_concern)
145146

146147
if use_op_msg:
@@ -196,7 +197,7 @@ async def command(
196197
reply = None
197198
response_doc: _DocumentOut = {"ok": 1}
198199
else:
199-
reply = await async_receive_message(conn, request_id, enable_pending=bool(applied_csot))
200+
reply = await async_receive_message(conn, request_id, enable_pending=applied_csot)
200201
conn.more_to_come = reply.more_to_come
201202
unpacked_docs = reply.unpack_response(
202203
codec_options=codec_options, user_fields=user_fields

Diff for: pymongo/asynchronous/pool.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def __init__(
194194

195195
def mark_pending(self, nbytes: int) -> None:
196196
"""Mark this connection as having a pending response."""
197-
# TODO: add "if self.enable_pending:"
198197
self.pending_response = True
199198
self.pending_bytes = nbytes
200199
self.pending_deadline = time.monotonic() + 3 # 3 seconds timeout for pending response
@@ -204,7 +203,6 @@ async def complete_pending(self) -> None:
204203
if not self.pending_response:
205204
return
206205

207-
timeout: Optional[Union[float, int]]
208206
timeout = self.conn.gettimeout
209207
if _csot.get_timeout():
210208
deadline = min(_csot.get_deadline(), self.pending_deadline)
@@ -219,7 +217,7 @@ async def complete_pending(self) -> None:
219217
await self.receive_message(None, True)
220218
else:
221219
# In sync we need to track the bytes left for the message.
222-
network_layer.receive_data(self.conn.get_conn, self.pending_byte, deadline)
220+
network_layer.receive_data(self.conn, self.pending_bytes, deadline)
223221
self.pending_response = False
224222
self.pending_bytes = 0
225223
self.pending_deadline = 0.0

Diff for: pymongo/message.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ def __init__(
16151615
self.exhaust = exhaust
16161616
self._pending_enabled = False
16171617

1618-
def pending_enabled(self):
1618+
def pending_enabled(self) -> bool:
16191619
return self._pending_enabled
16201620

16211621
def reset(self) -> None:
@@ -1789,7 +1789,7 @@ def __init__(
17891789
self.comment = comment
17901790
self._pending_enabled = False
17911791

1792-
def pending_enabled(self):
1792+
def pending_enabled(self) -> bool:
17931793
return self._pending_enabled
17941794

17951795
def reset(self) -> None:

Diff for: pymongo/network_layer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ def receive_message(
784784
op_code, _, compressor_id = _UNPACK_COMPRESSION_HEADER(
785785
receive_data(conn, 9, deadline, enable_pending)
786786
)
787-
data = decompress(receive_data(conn, length - 25, deadline), compressor_id, enable_pending)
787+
data = decompress(receive_data(conn, length - 25, deadline, enable_pending), compressor_id)
788788
else:
789789
data = receive_data(conn, length - 16, deadline, enable_pending)
790790

Diff for: pymongo/synchronous/network.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def command(
140140
# Support CSOT
141141
applied_csot = False
142142
if client:
143-
applied_csot = conn.apply_timeout(client, spec)
143+
res = conn.apply_timeout(client, spec)
144+
applied_csot = bool(res)
144145
_csot.apply_write_concern(spec, write_concern)
145146

146147
if use_op_msg:
@@ -196,7 +197,7 @@ def command(
196197
reply = None
197198
response_doc: _DocumentOut = {"ok": 1}
198199
else:
199-
reply = receive_message(conn, request_id, enable_pending=bool(applied_csot))
200+
reply = receive_message(conn, request_id, enable_pending=applied_csot)
200201
conn.more_to_come = reply.more_to_come
201202
unpacked_docs = reply.unpack_response(
202203
codec_options=codec_options, user_fields=user_fields

Diff for: pymongo/synchronous/pool.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def __init__(
194194

195195
def mark_pending(self, nbytes: int) -> None:
196196
"""Mark this connection as having a pending response."""
197-
# TODO: add "if self.enable_pending:"
198197
self.pending_response = True
199198
self.pending_bytes = nbytes
200199
self.pending_deadline = time.monotonic() + 3 # 3 seconds timeout for pending response
@@ -204,7 +203,6 @@ def complete_pending(self) -> None:
204203
if not self.pending_response:
205204
return
206205

207-
timeout: Optional[Union[float, int]]
208206
timeout = self.conn.gettimeout
209207
if _csot.get_timeout():
210208
deadline = min(_csot.get_deadline(), self.pending_deadline)
@@ -219,7 +217,7 @@ def complete_pending(self) -> None:
219217
self.receive_message(None, True)
220218
else:
221219
# In sync we need to track the bytes left for the message.
222-
network_layer.receive_data(self.conn.get_conn, self.pending_byte, deadline)
220+
network_layer.receive_data(self.conn, self.pending_bytes, deadline)
223221
self.pending_response = False
224222
self.pending_bytes = 0
225223
self.pending_deadline = 0.0

0 commit comments

Comments
 (0)