Skip to content

Commit

Permalink
Fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mukund-ananthu committed Sep 24, 2024
1 parent 6ec7c35 commit 7936911
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
12 changes: 5 additions & 7 deletions google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,26 +528,24 @@ def _retry_modacks(self, requests_to_retry):

ack_reqs_dict = {req.ack_id: req for req in requests_to_retry}

subscription_id: Optional[str] = None
project_id: Optional[str] = None
subscribe_links: List[trace.Link] = []
subscription_id = None
project_id = None
subscribe_links = []
for ack_req in ack_reqs_dict.values():
if ack_req.opentelemetry_data and math.isclose(ack_req.seconds, 0):
if subscription_id is None:
subscription_id = ack_req.opentelemetry_data.subscription_id
if project_id is None:
project_id = ack_req.opentelemetry_data.project_id
subscribe_span: Optional[
trace.Span
] = ack_req.opentelemetry_data.subscribe_span
subscribe_span = ack_req.opentelemetry_data.subscribe_span
if (
subscribe_span
and subscribe_span.get_span_context().trace_flags.sampled
):
subscribe_links.append(
trace.Link(subscribe_span.get_span_context())
)
nack_span: Optional[trace.Span] = None
nack_span = None
if subscription_id and project_id and len(subscribe_links) > 0:
nack_span = start_nack_span(
subscription_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1057,13 +1057,13 @@ def _send_lease_modacks(
with self._exactly_once_enabled_lock:
exactly_once_enabled = self._exactly_once_enabled
if exactly_once_enabled:
items: List[requests.ModAckRequest] = []
eod_items: List[requests.ModAckRequest] = []
if self._client.open_telemetry_enabled:
for ack_id, data in zip(
ack_ids, opentelemetry_data
): # pragma: NO COVER # Identical code covered in the same function below
assert data is not None
items.append(
eod_items.append(
requests.ModAckRequest(
ack_id,
ack_deadline,
Expand All @@ -1072,19 +1072,19 @@ def _send_lease_modacks(
)
)
else:
items = [
eod_items = [
requests.ModAckRequest(ack_id, ack_deadline, futures.Future())
for ack_id in ack_ids
]

assert self._dispatcher is not None
self._dispatcher.modify_ack_deadline(items, ack_deadline)
self._dispatcher.modify_ack_deadline(eod_items, ack_deadline)
if (
modack_span
): # pragma: NO COVER # Identical code covered in the same function below
modack_span.end()
expired_ack_ids = set()
for req in items:
for req in eod_items:
try:
assert req.future is not None
req.future.result()
Expand Down

0 comments on commit 7936911

Please sign in to comment.