Skip to content

Conversation

@googlyrahman
Copy link

@googlyrahman googlyrahman commented Dec 8, 2025

This PR introduces an abstract class to support the upcoming async client for the Python SDK. This refactor defines the public interface and enables code sharing between sync and async client, without introducing new logic.

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/python-storage API. labels Dec 8, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @googlyrahman, 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 refactors the client initialization process by introducing an abstract base class, BaseClient, which centralizes common setup procedures for client objects. This change extracts duplicated logic related to project configuration, credential management, and API endpoint resolution from the concrete Client class. The result is a cleaner, more maintainable Client implementation that leverages inheritance for shared functionality, improving consistency and reducing code redundancy across the library.

Highlights

  • New Abstract Base Class: Introduced BaseClient as a new abstract base class in google/cloud/storage/abstracts/base_client.py to house common client initialization logic.
  • Client Refactoring: The existing Client class in google/cloud/storage/client.py now inherits from the new BaseClient, significantly streamlining its __init__ method by delegating shared setup responsibilities.
  • Centralized Initialization Logic: Moved complex logic for project and credential handling, API endpoint determination (including emulator and universe domain overrides), and universe domain validation from Client to BaseClient.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new abstract BaseClient class in google/cloud/storage/abstracts/base_client.py to centralize common client initialization logic, including project and credential handling, API endpoint determination based on client options and environment variables (like emulator settings and universe domain), and api_key processing. The existing Client class in google/cloud/storage/client.py is refactored to inherit from this BaseClient, significantly simplifying its __init__ method by delegating most of the setup to the superclass and removing redundant imports. Review comments suggest modifying the BaseClient constructor to avoid a mutable default argument for extra_headers and removing an informal comment in the Client class regarding connection_kw_args.

@googlyrahman googlyrahman force-pushed the dev-final branch 7 times, most recently from 561e4a8 to 3f460e2 Compare December 8, 2025 20:45
@googlyrahman googlyrahman changed the title Introduce the base abstract class feat(storage): Introduce base abstract class for client Dec 8, 2025
@googlyrahman googlyrahman force-pushed the dev-final branch 2 times, most recently from 6ff0c15 to ba36be8 Compare December 8, 2025 21:25
@googlyrahman googlyrahman marked this pull request as ready for review December 8, 2025 21:36
@googlyrahman googlyrahman requested review from a team as code owners December 8, 2025 21:36
@googlyrahman googlyrahman changed the base branch from main to async December 9, 2025 07:19
@googlyrahman googlyrahman added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Dec 9, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Dec 9, 2025
@googlyrahman googlyrahman changed the title feat(storage): Introduce base abstract class for client feat(storage): Introduce base abstract class for storage client Dec 9, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 9, 2025
@googlyrahman googlyrahman enabled auto-merge (squash) December 18, 2025 06:17
@googlyrahman googlyrahman added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Dec 19, 2025
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Dec 19, 2025
@googlyrahman googlyrahman requested a review from a team as a code owner December 19, 2025 11:07
@googlyrahman googlyrahman merged commit 27d5e7d into googleapis:async Dec 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the googleapis/python-storage API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants