Skip to content

Commit de7e4e4

Browse files
committed
style(bigtable): use f-string and 'cannot' in MutationsBatcher.mutate
1 parent 53878ed commit de7e4e4

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

‎packages/google-cloud-bigtable/google/cloud/bigtable/batcher.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,13 @@ def mutate(self, row):
189189
"""
190190
if not isinstance(row, DirectRow):
191191
raise TypeError(
192-
"Bulk processing can not be applied for conditional or append mutations."
192+
"Bulk processing cannot be applied for conditional or append mutations."
193193
)
194194
if row.table is not None and row.table.name != self.table.name:
195195
from google.cloud.bigtable.table import TableMismatchError
196196

197197
raise TableMismatchError(
198-
"Row %s is a part of %s table. Current table: %s"
199-
% (row.row_key, row.table.name, self.table.name)
198+
f"Row {row.row_key} is a part of {row.table.name} table. Current table: {self.table.name}"
200199
)
201200
self._batcher.append(RowMutationEntry(row.row_key, row._get_mutations()))
202201

‎packages/google-cloud-bigtable/tests/unit/v2_client/test_batcher.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,19 +397,19 @@ def test_mutations_batcher_mutate_wrong_row_type(_setup_batcher):
397397
with MutationsBatcher(table=table, flush_count=1) as mutation_batcher:
398398
with pytest.raises(
399399
TypeError,
400-
match="Bulk processing can not be applied for conditional or append mutations.",
400+
match="Bulk processing cannot be applied for conditional or append mutations.",
401401
):
402402
mutation_batcher.mutate(cond_row)
403403

404404
with pytest.raises(
405405
TypeError,
406-
match="Bulk processing can not be applied for conditional or append mutations.",
406+
match="Bulk processing cannot be applied for conditional or append mutations.",
407407
):
408408
mutation_batcher.mutate(append_row)
409409

410410
with pytest.raises(
411411
TypeError,
412-
match="Bulk processing can not be applied for conditional or append mutations.",
412+
match="Bulk processing cannot be applied for conditional or append mutations.",
413413
):
414414
mutation_batcher.mutate_rows([cond_row])
415415

@@ -424,9 +424,9 @@ def test_mutations_batcher_mutate_table_mismatch(_setup_batcher):
424424
row = DirectRow(row_key=b"row_key", table=other_table)
425425
row.set_cell("cf1", b"c1", b"val")
426426

427-
expected_msg = r"Row b'row_key' is a part of %s table\. Current table: %s" % (
428-
other_table.name,
429-
table.name,
427+
expected_msg = (
428+
rf"Row b'row_key' is a part of {other_table.name} table\. "
429+
rf"Current table: {table.name}"
430430
)
431431

432432
with MutationsBatcher(table=table, flush_count=1) as mutation_batcher:

0 commit comments

Comments
 (0)