Skip to content

Conversation

@ohmayr
Copy link
Contributor

@ohmayr ohmayr commented Feb 2, 2026

Update scripts to be compatible with the latest changes in gapic-generator to generate import statements.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ohmayr, 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 updates the internal configuration files responsible for post-processing generated client library code. The changes are necessary to align with recent modifications in the gapic-generator tool, which now produces import statements in a different format. By adjusting the before patterns in the replacement rules, the post-processing logic will correctly identify and modify the newly generated import statements, ensuring the continued integrity and functionality of the client libraries.

Highlights

  • Import Statement Format Update: Modified the before patterns in various post-processing YAML scripts to reflect a change in how import statements are generated by gapic-generator. Specifically, from <module> import <name> is now matched as import <module> as <name>.
  • Compatibility with gapic-generator: Ensured that the client post-processing scripts remain compatible with the latest output from gapic-generator, which has altered its import statement generation logic.
  • Targeted Replacements: Updated replacement rules for specific protobuf-related imports (e.g., policy_pb2, severity_pb2, attestation_pb2, configmanagement_pb2) across multiple client libraries.
Changelog
  • .librarian/generator-input/client-post-processing/containeranalysis-grafeas-integration.yaml
    • Updated the before pattern for google.iam.v1.policy_pb2 import to match import google.iam.v1.policy_pb2 as policy_pb2.
    • Updated the before pattern for grafeas.v1.severity_pb2 import to match import grafeas.v1.severity_pb2 as severity_pb2.
  • .librarian/generator-input/client-post-processing/proto-plus-dependency-with-modified-namespace.yaml
    • Updated the before pattern for grafeas.v1.attestation_pb2 import to match import grafeas.v1.attestation_pb2 as attestation_pb2.
    • Updated the before pattern for google.iam.v2.policy_pb2 import to match import google.iam.v2.policy_pb2 as policy_pb2.
  • .librarian/generator-input/client-post-processing/remove-unused-imports.yaml
    • Updated before patterns for google.cloud.gkehub.configmanagement.v1.configmanagement_pb2 and google.cloud.gkehub.multiclusteringress.v1.multiclusteringress_pb2 imports to the import ... as ... style.
    • Updated before patterns for grafeas.v1.attestation_pb2 and grafeas.v1.common_pb2 imports to the import ... as ... style.
  • .librarian/generator-input/client-post-processing/sub-api-versioned-namespace.yaml
    • Updated before patterns for google.cloud.gkehub.configmanagement.v1.configmanagement_pb2 and google.cloud.gkehub.multiclusteringress.v1.multiclusteringress_pb2 imports to the import ... as ... style.
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 updates several YAML configuration files used for post-processing generated client code. The changes adapt the find-and-replace rules to a new import style (import ... as ... instead of from ... import ...) presumably now used by the gapic-generator. The modifications are consistent across all files and correctly reflect this change. I've pointed out a minor issue in one of the files where literal \n characters are used within YAML literal blocks, which is likely incorrect, and have suggested removing them.

]
before: |
from google.iam.v1 import policy_pb2 # type: ignore\n
import google.iam.v1.policy_pb2 as policy_pb2 # type: ignore\n
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The explicit \n at the end of this line is likely unnecessary. In a YAML literal block (|), newlines are already preserved. This will cause the replacement tool to search for a line ending with the literal characters \ and n before the newline, which is probably not the intention.

      import google.iam.v1.policy_pb2 as policy_pb2  # type: ignore

from google.iam.v1 import policy_pb2 # type: ignore
import google.iam.v1.policy_pb2 as policy_pb2 # type: ignore
from grafeas import grafeas_v1
from grafeas.grafeas_v1.services.grafeas import transports\n
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the before: block, the explicit \n here is likely incorrect. The literal block scalar (|) already handles the newline. This will result in adding a literal \n at the end of the line in the target file.

      from grafeas.grafeas_v1.services.grafeas import transports

@ohmayr ohmayr marked this pull request as ready for review February 3, 2026 01:03
@ohmayr ohmayr requested review from a team as code owners February 3, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant