Skip to content

Commit d489ad3

Browse files
committed
cleaned up imports
1 parent e8d122e commit d489ad3

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

google/cloud/bigtable/data/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
CrossSync.add_mapping("_ReadRowsOperation", _ReadRowsOperationAsync)
6262
CrossSync.add_mapping("_MutateRowsOperation", _MutateRowsOperationAsync)
6363
CrossSync.add_mapping("ExecuteQueryIterator", ExecuteQueryIteratorAsync)
64+
CrossSync.add_mapping("MutationsBatcher", MutationsBatcherAsync)
6465

6566

6667
__version__: str = package_version.__version__

google/cloud/bigtable/data/_async/client.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,25 @@
8383
from google.cloud.bigtable_v2.services.bigtable.transports import (
8484
BigtableGrpcAsyncIOTransport as TransportType,
8585
)
86-
from google.cloud.bigtable.data._async.mutations_batcher import (
87-
MutationsBatcherAsync,
88-
_MB_SIZE,
89-
)
90-
from google.cloud.bigtable.data.execute_query._async.execute_query_iterator import (
91-
ExecuteQueryIteratorAsync,
92-
)
93-
86+
from google.cloud.bigtable.data._async.mutations_batcher import _MB_SIZE
9487
else:
9588
from grpc import insecure_channel
9689
from google.cloud.bigtable_v2.services.bigtable.transports import BigtableGrpcTransport as TransportType # type: ignore
97-
from google.cloud.bigtable.data._sync_autogen.mutations_batcher import ( # noqa: F401
98-
MutationsBatcher,
99-
_MB_SIZE,
100-
)
101-
from google.cloud.bigtable.data.execute_query._sync_autogen.execute_query_iterator import ( # noqa: F401
102-
ExecuteQueryIterator,
103-
)
10490

10591

10692
if TYPE_CHECKING:
10793
from google.cloud.bigtable.data._helpers import RowKeySamples
10894
from google.cloud.bigtable.data._helpers import ShardedQuery
10995

96+
if CrossSync.is_async:
97+
from google.cloud.bigtable.data._async.mutations_batcher import (
98+
MutationsBatcherAsync,
99+
)
100+
from google.cloud.bigtable.data.execute_query._async.execute_query_iterator import (
101+
ExecuteQueryIteratorAsync,
102+
)
103+
104+
110105
__CROSS_SYNC_OUTPUT__ = "google.cloud.bigtable.data._sync_autogen.client"
111106

112107

@@ -372,8 +367,8 @@ async def _manage_channel(
372367
await old_channel.close(grace_period)
373368
else:
374369
if grace_period:
375-
self._is_closed.wait(grace_period)
376-
old_channel.close()
370+
self._is_closed.wait(grace_period) # type: ignore
371+
old_channel.close() # type: ignore
377372
# subtract thed time spent waiting for the channel to be replaced
378373
next_refresh = random.uniform(refresh_interval_min, refresh_interval_max)
379374
next_sleep = max(next_refresh - (time.monotonic() - start_timestamp), 0)
@@ -421,7 +416,7 @@ async def _register_instance(
421416
}
422417
)
423418
async def _remove_instance_registration(
424-
self, instance_id: str, owner: TableAsync | ExecuteQueryIteratorAsync
419+
self, instance_id: str, owner: TableAsync | "ExecuteQueryIteratorAsync"
425420
) -> bool:
426421
"""
427422
Removes an instance from the client's registered instances, to prevent
@@ -585,7 +580,7 @@ async def execute_query(
585580
"proto_format": {},
586581
}
587582

588-
return ExecuteQueryIteratorAsync(
583+
return CrossSync.ExecuteQueryIterator(
589584
self,
590585
instance_id,
591586
app_profile_id,
@@ -1132,7 +1127,7 @@ def mutations_batcher(
11321127
batch_attempt_timeout: float | None | TABLE_DEFAULT = TABLE_DEFAULT.MUTATE_ROWS,
11331128
batch_retryable_errors: Sequence[type[Exception]]
11341129
| TABLE_DEFAULT = TABLE_DEFAULT.MUTATE_ROWS,
1135-
) -> MutationsBatcherAsync:
1130+
) -> "MutationsBatcherAsync":
11361131
"""
11371132
Returns a new mutations batcher instance.
11381133

google/cloud/bigtable/data/_async/mutations_batcher.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ async def add_to_flow(self, mutations: RowMutationEntry | list[RowMutationEntry]
176176
yield mutations[start_idx:end_idx]
177177

178178

179-
@CrossSync.convert_class(
180-
sync_name="MutationsBatcher", add_mapping_for_name="MutationsBatcher"
181-
)
179+
@CrossSync.convert_class(sync_name="MutationsBatcher")
182180
class MutationsBatcherAsync:
183181
"""
184182
Allows users to send batches using context manager API:

google/cloud/bigtable/data/execute_query/_async/execute_query_iterator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
if TYPE_CHECKING:
4747
if CrossSync.is_async:
4848
from google.cloud.bigtable.data import BigtableDataClientAsync as DataClientType
49-
else:
50-
from google.cloud.bigtable.data import BigtableDataClient as DataClientType
5149

5250
__CROSS_SYNC_OUTPUT__ = (
5351
"google.cloud.bigtable.data.execute_query._sync_autogen.execute_query_iterator"

0 commit comments

Comments
 (0)