Skip to content

Commit f62439a

Browse files
committed
fix: address coverage and lint issues failing presubmits
1 parent 7cf9fbf commit f62439a

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

google/api_core/retry/retry_streaming_async.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,15 @@ async def retry_target_stream(
163163

164164
# TODO: Remove this conditional once the minimum supported Python version is 3.11
165165
if sys.version_info[:3] >= (3, 11, 0):
166-
await cast(AsyncGenerator["_Y", None], target_iterator).athrow(
167-
sys.exception()) # type: ignore
166+
await cast(
167+
AsyncGenerator["_Y", None], target_iterator
168+
).athrow(
169+
sys.exception() # type: ignore
170+
)
168171
else:
169-
await cast(AsyncGenerator["_Y", None], target_iterator).athrow(
170-
*sys.exc_info())
172+
await cast(
173+
AsyncGenerator["_Y", None], target_iterator
174+
).athrow(*sys.exc_info())
171175
else:
172176
raise
173177
return

tests/unit/retry/test_retry_base.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import re
1717

1818
import mock
19+
import pytest
1920
import requests.exceptions
2021

2122
from google.api_core import exceptions
@@ -136,7 +137,8 @@ def test_constructor_options(self):
136137
assert retry_._timeout == 4
137138
assert retry_._on_error is _some_function
138139

139-
def test_with_timeout(self):
140+
@pytest.mark.parametrize("use_deadline", [True, False])
141+
def test_with_timeout(self, use_deadline):
140142
retry_ = self._make_one(
141143
predicate=mock.sentinel.predicate,
142144
initial=1,
@@ -145,9 +147,12 @@ def test_with_timeout(self):
145147
timeout=4,
146148
on_error=mock.sentinel.on_error,
147149
)
148-
new_retry = retry_.with_timeout(42)
150+
new_retry = (
151+
retry_.with_timeout(42) if not use_deadline else retry_.with_deadline(42)
152+
)
149153
assert retry_ is not new_retry
150154
assert new_retry._timeout == 42
155+
assert new_retry.timeout == 42 if not use_deadline else new_retry.deadline == 42
151156

152157
# the rest of the attributes should remain the same
153158
assert new_retry._predicate is retry_._predicate

0 commit comments

Comments
 (0)