Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit de5d07b

Browse files
committed
fixed context manager naming; lint
1 parent 96d1355 commit de5d07b

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

google/cloud/bigtable/data/_metrics/data_model.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
from __future__ import annotations
1515

16-
from typing import Callable, Tuple, cast, TYPE_CHECKING
16+
from typing import Tuple, cast, TYPE_CHECKING
1717

1818
import time
1919
import re
@@ -146,7 +146,9 @@ class ActiveOperationMetric:
146146
uuid: str = field(default_factory=lambda: str(uuid.uuid4()))
147147
# create a default backoff generator, initialized with standard default backoff values
148148
backoff_generator: TrackedBackoffGenerator = field(
149-
default_factory=lambda: TrackedBackoffGenerator(initial=0.01, maximum=60, multiplier=2)
149+
default_factory=lambda: TrackedBackoffGenerator(
150+
initial=0.01, maximum=60, multiplier=2
151+
)
150152
)
151153
# keep monotonic timestamps for active operations
152154
start_time_ns: int = field(default_factory=time.monotonic_ns)
@@ -187,7 +189,7 @@ def start(self) -> None:
187189
return self._handle_error(INVALID_STATE_ERROR.format("start", self.state))
188190
self.start_time_ns = time.monotonic_ns()
189191

190-
def start_attempt(self) -> ActiveAttemptMetric:
192+
def start_attempt(self) -> ActiveAttemptMetric | None:
191193
"""
192194
Called to initiate a new attempt for the operation.
193195
@@ -204,9 +206,7 @@ def start_attempt(self) -> ActiveAttemptMetric:
204206
try:
205207
# find backoff value before this attempt
206208
prev_attempt_idx = len(self.completed_attempts) - 1
207-
backoff = self.backoff_generator.get_attempt_backoff(
208-
prev_attempt_idx
209-
)
209+
backoff = self.backoff_generator.get_attempt_backoff(prev_attempt_idx)
210210
# generator will return the backoff time in seconds, so convert to nanoseconds
211211
backoff_ns = int(backoff * 1e9)
212212
except IndexError:
@@ -413,7 +413,7 @@ def _handle_error(message: str) -> None:
413413
full_message = f"Error in Bigtable Metrics: {message}"
414414
LOGGER.warning(full_message)
415415

416-
def __aenter__(self):
416+
def __enter__(self):
417417
"""
418418
Implements the async manager protocol
419419
@@ -423,7 +423,7 @@ def __aenter__(self):
423423
"""
424424
return self
425425

426-
def __aexit__(self, exc_type, exc_val, exc_tb):
426+
def __exit__(self, exc_type, exc_val, exc_tb):
427427
"""
428428
Implements the context manager protocol
429429

google/cloud/bigtable/data/_metrics/handlers/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ def on_operation_cancelled(self, op: ActiveOperationMetric) -> None:
3535
def on_attempt_complete(
3636
self, attempt: CompletedAttemptMetric, op: ActiveOperationMetric
3737
) -> None:
38-
pass
38+
pass

0 commit comments

Comments
 (0)