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

Commit 4013354

Browse files
fix: fix mypy. for timeouts specifically handling None
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
1 parent da33b9c commit 4013354

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

google/auth/aio/transport/sessions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ async def request(
238238
retries = _exponential_backoff.AsyncExponentialBackoff(
239239
total_attempts=transport.DEFAULT_MAX_RETRY_ATTEMPTS
240240
)
241+
timeout_float: float
241242
if headers is None:
242243
headers = {}
243244
async with timeout_guard(max_allowed_time) as with_timeout:
@@ -248,10 +249,12 @@ async def request(
248249
)
249250
)
250251
if timeout is None:
251-
timeout_float = 0.0 # Or your preferred default numeric timeout
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)
252256
else:
253-
# Narrow the type: if it's an aiohttp.ClientTimeout, extract the float 'total'
254-
timeout_float = timeout.total if hasattr(timeout, "total") else timeout
257+
timeout_float = float(timeout)
255258
# Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
256259
# See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
257260
async for _ in retries: # pragma: no branch

0 commit comments

Comments
 (0)