|
16 | 16 | from contextlib import asynccontextmanager |
17 | 17 | import functools |
18 | 18 | import time |
19 | | -import typing |
20 | | -from typing import Any, Mapping, Optional, Union |
| 19 | +from typing import Any, Mapping, Optional, TYPE_CHECKING, Union |
21 | 20 |
|
22 | 21 | from google.auth import _exponential_backoff, exceptions |
23 | 22 | from google.auth.aio import transport |
24 | 23 | from google.auth.aio.credentials import Credentials |
25 | 24 | from google.auth.exceptions import TimeoutError |
26 | 25 |
|
27 | | -try: |
28 | | - from google.auth.aio.transport.aiohttp import Request as AiohttpRequest |
29 | | - |
30 | | - AIOHTTP_INSTALLED = True |
31 | | -except ImportError: # pragma: NO COVER |
32 | | - AIOHTTP_INSTALLED = False |
33 | | - |
34 | | -if typing.TYPE_CHECKING: |
| 26 | +if TYPE_CHECKING: # pragma: NO COVER |
35 | 27 | from aiohttp import ClientTimeout # type: ignore |
36 | 28 |
|
37 | 29 | else: |
|
41 | 33 | except ImportError: |
42 | 34 | ClientTimeout = None |
43 | 35 |
|
| 36 | +try: |
| 37 | + from google.auth.aio.transport.aiohttp import Request as AiohttpRequest |
| 38 | + |
| 39 | + AIOHTTP_INSTALLED = True |
| 40 | +except ImportError: # pragma: NO COVER |
| 41 | + AIOHTTP_INSTALLED = False |
| 42 | + |
44 | 43 |
|
45 | 44 | @asynccontextmanager |
46 | 45 | async def timeout_guard(timeout): |
@@ -221,14 +220,14 @@ async def get( |
221 | 220 | url (str): The URI to be requested. |
222 | 221 | data (Optional[bytes]): The payload or body in HTTP request. |
223 | 222 | headers (Optional[Mapping[str, str]]): Request headers. |
224 | | - timeout (float, aiohttp.ClientTimeout): |
225 | | - The amount of time in seconds to wait for the server response |
226 | | - with each individual request. |
227 | 223 | max_allowed_time (float): |
228 | 224 | If the method runs longer than this, a ``Timeout`` exception is |
229 | 225 | automatically raised. Unlike the ``timeout`` parameter, this |
230 | 226 | value applies to the total method execution time, even if |
231 | 227 | multiple requests are made under the hood. |
| 228 | + timeout (float, aiohttp.ClientTimeout): |
| 229 | + The amount of time in seconds to wait for the server response |
| 230 | + with each individual request. |
232 | 231 | total_attempts (int): |
233 | 232 | The total number of retry attempts. |
234 | 233 |
|
@@ -274,14 +273,14 @@ async def post( |
274 | 273 | url (str): The URI to be requested. |
275 | 274 | data (Optional[bytes]): The payload or body in HTTP request. |
276 | 275 | headers (Optional[Mapping[str, str]]): Request headers. |
277 | | - timeout (float, aiohttp.ClientTimeout): |
278 | | - The amount of time in seconds to wait for the server response |
279 | | - with each individual request. |
280 | 276 | max_allowed_time (float): |
281 | 277 | If the method runs longer than this, a ``Timeout`` exception is |
282 | 278 | automatically raised. Unlike the ``timeout`` parameter, this |
283 | 279 | value applies to the total method execution time, even if |
284 | 280 | multiple requests are made under the hood. |
| 281 | + timeout (float, aiohttp.ClientTimeout): |
| 282 | + The amount of time in seconds to wait for the server response |
| 283 | + with each individual request. |
285 | 284 | total_attempts (int): |
286 | 285 | The total number of retry attempts. |
287 | 286 |
|
@@ -327,14 +326,14 @@ async def put( |
327 | 326 | url (str): The URI to be requested. |
328 | 327 | data (Optional[bytes]): The payload or body in HTTP request. |
329 | 328 | headers (Optional[Mapping[str, str]]): Request headers. |
330 | | - timeout (float, aiohttp.ClientTimeout): |
331 | | - The amount of time in seconds to wait for the server response |
332 | | - with each individual request. |
333 | 329 | max_allowed_time (float): |
334 | 330 | If the method runs longer than this, a ``Timeout`` exception is |
335 | 331 | automatically raised. Unlike the ``timeout`` parameter, this |
336 | 332 | value applies to the total method execution time, even if |
337 | 333 | multiple requests are made under the hood. |
| 334 | + timeout (float, aiohttp.ClientTimeout): |
| 335 | + The amount of time in seconds to wait for the server response |
| 336 | + with each individual request. |
338 | 337 | total_attempts (int): |
339 | 338 | The total number of retry attempts. |
340 | 339 |
|
@@ -380,14 +379,14 @@ async def patch( |
380 | 379 | url (str): The URI to be requested. |
381 | 380 | data (Optional[bytes]): The payload or body in HTTP request. |
382 | 381 | headers (Optional[Mapping[str, str]]): Request headers. |
383 | | - timeout (float, aiohttp.ClientTimeout): |
384 | | - The amount of time in seconds to wait for the server response |
385 | | - with each individual request. |
386 | 382 | max_allowed_time (float): |
387 | 383 | If the method runs longer than this, a ``Timeout`` exception is |
388 | 384 | automatically raised. Unlike the ``timeout`` parameter, this |
389 | 385 | value applies to the total method execution time, even if |
390 | 386 | multiple requests are made under the hood. |
| 387 | + timeout (float, aiohttp.ClientTimeout): |
| 388 | + The amount of time in seconds to wait for the server response |
| 389 | + with each individual request. |
391 | 390 | total_attempts (int): |
392 | 391 | The total number of retry attempts. |
393 | 392 |
|
@@ -433,14 +432,14 @@ async def delete( |
433 | 432 | url (str): The URI to be requested. |
434 | 433 | data (Optional[bytes]): The payload or body in HTTP request. |
435 | 434 | headers (Optional[Mapping[str, str]]): Request headers. |
436 | | - timeout (float, aiohttp.ClientTimeout): |
437 | | - The amount of time in seconds to wait for the server response |
438 | | - with each individual request. |
439 | 435 | max_allowed_time (float): |
440 | 436 | If the method runs longer than this, a ``Timeout`` exception is |
441 | 437 | automatically raised. Unlike the ``timeout`` parameter, this |
442 | 438 | value applies to the total method execution time, even if |
443 | 439 | multiple requests are made under the hood. |
| 440 | + timeout (float, aiohttp.ClientTimeout): |
| 441 | + The amount of time in seconds to wait for the server response |
| 442 | + with each individual request. |
444 | 443 | total_attempts (int): |
445 | 444 | The total number of retry attempts. |
446 | 445 |
|
|
0 commit comments