Skip to content

Commit 774d691

Browse files
author
zhixiangli
committed
style: minor formatting and import cleanup
1 parent 7b706fc commit 774d691

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

packages/google-cloud-storage/google/cloud/storage/asyncio/async_multi_range_downloader.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626
from google.cloud import _storage_v2
2727
from google.cloud.storage._helpers import generate_random_56_bit_integer
28+
from google.cloud.storage.asyncio._stream_multiplexer import (
29+
_StreamEnd,
30+
_StreamError,
31+
_StreamMultiplexer,
32+
)
2833
from google.cloud.storage.asyncio.async_grpc_client import (
2934
AsyncGrpcClient,
3035
)
@@ -39,12 +44,6 @@
3944
_DownloadState,
4045
_ReadResumptionStrategy,
4146
)
42-
from google.cloud.storage.asyncio._stream_multiplexer import (
43-
_StreamMultiplexer,
44-
_StreamError,
45-
_StreamEnd,
46-
)
47-
4847

4948
from ._utils import raise_if_no_fast_crc32c
5049

@@ -358,9 +357,7 @@ async def factory():
358357
)
359358
)
360359

361-
await stream.open(
362-
metadata=current_metadata if current_metadata else None
363-
)
360+
await stream.open(metadata=current_metadata if current_metadata else None)
364361

365362
if stream.generation_number:
366363
self.generation = stream.generation_number
@@ -459,17 +456,18 @@ async def generator():
459456

460457
# Reopen stream if needed
461458
should_reopen = (
462-
(attempt_count > 1 and last_broken_generation is not None)
463-
or (attempt_count == 1 and metadata is not None)
464-
)
459+
attempt_count > 1 and last_broken_generation is not None
460+
) or (attempt_count == 1 and metadata is not None)
465461
if should_reopen:
466462
broken_gen = (
467463
last_broken_generation
468464
if attempt_count > 1
469465
else self._multiplexer.stream_generation
470466
)
471467
stream_factory = self._create_stream_factory(state, metadata)
472-
await self._multiplexer.reopen_stream(broken_gen, stream_factory)
468+
await self._multiplexer.reopen_stream(
469+
broken_gen, stream_factory
470+
)
473471

474472
my_generation = self._multiplexer.stream_generation
475473

@@ -478,9 +476,7 @@ async def generator():
478476
for i in range(
479477
0, len(requests), _MAX_READ_RANGES_PER_BIDI_READ_REQUEST
480478
):
481-
batch = requests[
482-
i : i + _MAX_READ_RANGES_PER_BIDI_READ_REQUEST
483-
]
479+
batch = requests[i : i + _MAX_READ_RANGES_PER_BIDI_READ_REQUEST]
484480
try:
485481
await self._multiplexer.send(
486482
_storage_v2.BidiReadObjectRequest(read_ranges=batch)

packages/google-cloud-storage/tests/system/test_zonal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# py standard imports
2-
import random
32
import asyncio
43
import gc
54
import os
5+
import random
66
import uuid
77
from io import BytesIO
88

packages/google-cloud-storage/tests/unit/asyncio/test_async_multi_range_downloader.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ async def controlled_recv():
213213
second_buffer = BytesIO()
214214

215215
task1 = asyncio.create_task(mock_mrd.download_ranges([(0, 18, buffer)]))
216-
task2 = asyncio.create_task(
217-
mock_mrd.download_ranges([(10, 6, second_buffer)])
218-
)
216+
task2 = asyncio.create_task(mock_mrd.download_ranges([(10, 6, second_buffer)]))
219217
await asyncio.gather(task1, task2)
220218

221219
assert buffer.getvalue() == data
@@ -323,10 +321,10 @@ def test_init_raises_if_crc32c_c_extension_is_missing(self, mock_google_crc32c):
323321
async def test_download_ranges_raises_on_checksum_mismatch(
324322
self, mock_checksum_class
325323
):
324+
from google.cloud.storage.asyncio._stream_multiplexer import _StreamMultiplexer
326325
from google.cloud.storage.asyncio.async_multi_range_downloader import (
327326
AsyncMultiRangeDownloader,
328327
)
329-
from google.cloud.storage.asyncio._stream_multiplexer import _StreamMultiplexer
330328

331329
mock_client = mock.MagicMock()
332330
mock_stream = mock.AsyncMock(

packages/google-cloud-storage/tests/unit/asyncio/test_stream_multiplexer.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
# limitations under the License.
1414

1515
import asyncio
16-
import pytest
1716
from unittest.mock import AsyncMock, MagicMock
1817

18+
import pytest
19+
1920
from google.cloud import _storage_v2
2021
from google.cloud.storage.asyncio._stream_multiplexer import (
21-
_StreamMultiplexer,
22-
_StreamError,
23-
_StreamEnd,
2422
_DEFAULT_QUEUE_MAX_SIZE,
23+
_StreamEnd,
24+
_StreamError,
25+
_StreamMultiplexer,
2526
)
2627

2728

@@ -291,7 +292,9 @@ async def test_send_forwards_to_stream(self):
291292
mux = _StreamMultiplexer(mock_stream)
292293

293294
request = _storage_v2.BidiReadObjectRequest(
294-
read_ranges=[_storage_v2.ReadRange(read_id=1, read_offset=0, read_length=10)]
295+
read_ranges=[
296+
_storage_v2.ReadRange(read_id=1, read_offset=0, read_length=10)
297+
]
295298
)
296299
gen = await mux.send(request)
297300
mock_stream.send.assert_called_once_with(request)

0 commit comments

Comments
 (0)