Skip to content

Commit 0b4e6a7

Browse files
committed
address gemini bot comments
1 parent 8c2a143 commit 0b4e6a7

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

google/cloud/storage/_experimental/asyncio/retry/writes_resumption_strategy.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(
4747
self.user_buffer = user_buffer
4848
self.persisted_size: int = 0
4949
self.bytes_sent: int = 0
50-
self.write_handle: Union[bytes, Any, None] = None
50+
self.write_handle: Union[bytes, storage_type.BidiWriteHandle, None] = None
5151
self.routing_token: Optional[str] = None
5252
self.is_complete: bool = False
5353

@@ -65,9 +65,6 @@ def generate_requests(
6565
"""
6666
write_state: _WriteState = state["write_state"]
6767

68-
# Mark that we have generated the first request for this stream attempt
69-
state["first_request"] = False
70-
7168
if write_state.write_handle:
7269
write_state.spec.write_handle = write_state.write_handle
7370

@@ -141,6 +138,3 @@ async def recover_state_on_failure(
141138
# Reset the user buffer to the last known good byte.
142139
write_state.user_buffer.seek(write_state.persisted_size)
143140
write_state.bytes_sent = write_state.persisted_size
144-
145-
# Mark next pass as a retry (not the absolute first request)
146-
state["first_request"] = False

tests/unit/asyncio/retry/test_reads_resumption_strategy.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
from google.cloud._storage_v2.types.storage import BidiReadObjectRedirectedError
2828

2929
_READ_ID = 1
30-
LOGGER_NAME = "google.cloud.storage._experimental.asyncio.retry.reads_resumption_strategy"
30+
LOGGER_NAME = (
31+
"google.cloud.storage._experimental.asyncio.retry.reads_resumption_strategy"
32+
)
3133

3234

3335
class TestDownloadState(unittest.TestCase):
@@ -309,7 +311,9 @@ def test_update_state_missing_read_range_logs_warning(self):
309311
with self.assertLogs(LOGGER_NAME, level="WARNING") as cm:
310312
self.strategy.update_state_from_response(response, self.state)
311313

312-
self.assertTrue(any("missing read_range field" in output for output in cm.output))
314+
self.assertTrue(
315+
any("missing read_range field" in output for output in cm.output)
316+
)
313317

314318
def test_update_state_unknown_id_logs_warning(self):
315319
"""Verify we log a warning and continue when read_id is unknown."""
@@ -320,8 +324,12 @@ def test_update_state_unknown_id_logs_warning(self):
320324
with self.assertLogs(LOGGER_NAME, level="WARNING") as cm:
321325
self.strategy.update_state_from_response(response, self.state)
322326

323-
self.assertTrue(any(f"unknown or stale read_id {unknown_id}" in output for output in cm.output))
324-
327+
self.assertTrue(
328+
any(
329+
f"unknown or stale read_id {unknown_id}" in output
330+
for output in cm.output
331+
)
332+
)
325333

326334
# --- Recovery Tests ---
327335

tests/unit/asyncio/retry/test_writes_resumption_strategy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,11 @@ def test_update_state_from_response(self):
218218
def test_update_state_from_response_ignores_smaller_persisted_size(self):
219219
strategy = self._make_one()
220220
state = {
221-
"write_state": _WriteState(None, 0, None),
221+
"write_state": _WriteState(
222+
mock.Mock(spec=storage_type.AppendObjectSpec),
223+
0,
224+
mock.Mock(spec=io.BytesIO),
225+
),
222226
}
223227
write_state = state["write_state"]
224228
write_state.persisted_size = 2048

tests/unit/asyncio/test_async_multi_range_downloader.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ async def test_download_ranges_via_async_gather(
143143
)
144144
]
145145
),
146-
None,
147146
_storage_v2.BidiReadObjectResponse(
148147
object_data_ranges=[
149148
_storage_v2.ObjectRangeData(

0 commit comments

Comments
 (0)