feat: Support timeout as aiohttp.ClientTimeout and total_attempts (max retries) in AsyncAuthorizedSession#1961
Conversation
Summary of ChangesHello @yinghsienwu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request enhances AsyncAuthorizedSession by allowing aiohttp.ClientTimeout objects to be passed as timeout and by introducing a total_attempts parameter to configure the maximum number of retries. The changes are well-implemented in the core request method.
However, there are a few areas for improvement:
- The convenience methods (
get,post,put,patch) have not been updated to accept and pass through the newtotal_attemptsparameter. This makes the new retry functionality unavailable when using these common methods. - The
deletemethod has not been updated at all, and still expectstimeoutto be afloat, and does not supporttotal_attempts. For consistency across the API, it should be updated as well. - There are a couple of minor style issues related to indentation and extra newlines.
I've added specific comments with suggestions to address these points. Overall, this is a valuable addition, and with these adjustments, it will be even better.
…x retries) in AsyncAuthorizedSession
| @@ -255,10 +271,11 @@ async def delete( | |||
| headers: Optional[Mapping[str, str]] = None, | |||
| max_allowed_time: float = transport._DEFAULT_TIMEOUT_SECONDS, | |||
| timeout: float = transport._DEFAULT_TIMEOUT_SECONDS, | |||
There was a problem hiding this comment.
should this not be updated to -Union[float, ClientTimeout] = transport._DEFAULT_TIMEOUT_SECONDS
google/auth/aio/transport/aiohttp.py
Outdated
| if typing.TYPE_CHECKING: | ||
| from aiohttp import ClientTimeout | ||
| else: | ||
| ClientTimeout: typing.Type = Any |
There was a problem hiding this comment.
nit: Using ClientTimeout: typing.Type = Any might be interpreted as ClientTimeout being a class type itself.
maybe we use ClientTimeout = Any or ClientTimeout: Any = Any
agrawalradhika-cell
left a comment
There was a problem hiding this comment.
You will have to fix the build failures before the merge, rest looks good to me!
|
/gemini review |
There was a problem hiding this comment.
Code Review
The pull request introduces support for aiohttp.ClientTimeout objects and a total_attempts parameter for retries in AsyncAuthorizedSession. The changes are well-implemented, including updated type hints, docstrings, and logic to handle the new parameters. The system tests and unit tests have also been updated to reflect these changes, ensuring proper functionality and coverage. The identified area for improvement, as detailed in the specific comments, is the conditional import logic for ClientTimeout to ensure correct runtime type resolution.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
b/485304839