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

Commit 064d524

Browse files
chore: fix: final mypy suppression for aiohttp timeout union
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
1 parent 4013354 commit 064d524

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

google/auth/aio/transport/sessions.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ async def request(
238238
retries = _exponential_backoff.AsyncExponentialBackoff(
239239
total_attempts=transport.DEFAULT_MAX_RETRY_ATTEMPTS
240240
)
241-
timeout_float: float
242241
if headers is None:
243242
headers = {}
244243
async with timeout_guard(max_allowed_time) as with_timeout:
@@ -248,19 +247,18 @@ async def request(
248247
self._auth_request, method, url, headers
249248
)
250249
)
251-
if timeout is None:
252-
timeout_float = 0.0
253-
# Use isinstance for better type narrowing if aiohttp is available
254-
elif AIOHTTP_INSTALLED and isinstance(timeout, aiohttp.ClientTimeout):
255-
timeout_float = float(timeout.total)
250+
if AIOHTTP_INSTALLED and hasattr(timeout, "total"):
251+
actual_timeout = float(timeout.total) # type: ignore
252+
elif timeout is None:
253+
actual_timeout = 0.0
256254
else:
257-
timeout_float = float(timeout)
255+
actual_timeout = timeout
258256
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
259257
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
260258
async for _ in retries: # pragma: no branch
261259
response = await with_timeout(
262260
self._auth_request(
263-
url, method, data, headers, timeout_float, **kwargs
261+
url, method, data, headers, actual_timeout, **kwargs
264262
)
265263
)
266264
if response.status_code not in transport.DEFAULT_RETRYABLE_STATUS_CODES:

0 commit comments

Comments
 (0)