Skip to content

Conversation

@haggit-eliyahu
Copy link
Contributor

@haggit-eliyahu haggit-eliyahu commented Jan 12, 2026


Description

handle statements of the format "import * as *".
some cases has to change it to "from * import * as *" due to using relative path.

Checklist:

Please ensure you have completed the following items before submitting your PR.
This helps us review your contribution faster and more efficiently.

General Checks:

  • I have read and followed the project's contributing.md guide.
  • My code follows the project's coding style guidelines.
  • I have performed a self-review of my own code.
  • My changes do not introduce any new warnings.
  • My changes pass all existing tests.
  • I have added new tests where appropriate to cover my changes. (If applicable)
  • I have updated the documentation where necessary (e.g., README, API docs). (If applicable)

Open-Source Specific Checks:

  • My changes do not introduce any Personally Identifiable Information (PII) or sensitive customer data.
  • My changes do not expose any internal-only code examples, configurations, or URLs.
  • All code examples, comments, and messages are generic and suitable for a public repository.
  • I understand that any internal context or sensitive details related to this work are handled separately in internal systems (Buganizer for Google team members).

For Google Team Members and Reviewers Only:

  • I have included the Buganizer ID in the PR title or description (e.g., "Internal Buganizer ID: 123456789" or "Related Buganizer: go/buganizer/123456789").
  • I have ensured that all internal discussions and PII related to this work remain in Buganizer.
  • I have tagged the PR with one or more labels that reflect the pull request purpose.

Screenshots (If Applicable)

If your changes involve UI or visual elements, please include screenshots or GIFs here.
Ensure any sensitive data is redacted or generalized.


Further Comments / Questions

Any additional comments, questions, or areas where you'd like specific feedback.

@haggit-eliyahu haggit-eliyahu requested a review from a team as a code owner January 12, 2026 09:32
@haggit-eliyahu haggit-eliyahu added Bug Something isn't working mp mp related change labels Jan 12, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @haggit-eliyahu, 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 resolves an issue with how Python 'import ... as ...' statements are processed by the project's code manipulation tools. Previously, these statements were not correctly transformed, especially when converting standard 'import' syntax to 'from ... import ...' for internal and SDK modules. The changes ensure that the 'as' alias is preserved during these transformations, enhancing the robustness of the code refactoring utilities and preventing potential import errors.

Highlights

  • Import 'as' statement resolution: Correctly handles 'import as ' and 'import . as ' statements within the code manipulation logic, ensuring the 'as' alias is preserved during transformations.
  • SdkImportTransformer enhancement: The SdkImportTransformer has been updated to correctly prefix SDK module imports while preserving any 'as' aliases, preventing incorrect module resolution.
  • Core package import transformation: Improved CorePackageImportTransformer to convert 'import manager.submodule as alias' into 'from ..core.manager import submodule as alias' and similar patterns for internal core modules, ensuring proper relative path handling.
  • Expanded test coverage: New test cases have been added to validate the correct handling of various 'import ... as ...' scenarios across different import transformers, increasing confidence in the robustness of the changes.
  • Version bump: The project version has been updated from '1.24.1' to '1.24.2' in 'pyproject.toml' and 'uv.lock', reflecting the bug fix.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 correctly addresses an issue where import ... as ... statements were not handled properly by the import transformers, causing aliases to be lost. The changes successfully preserve aliases and handle more complex import patterns. The accompanying tests are thorough and cover these new scenarios well.

However, I've identified a critical pre-existing issue in how import statements with multiple names (e.g., import os, sys) are processed. The current logic can lead to silently dropping imports, which could break code. I have provided two review comments with suggestions to address this critical bug, ensuring the transformers are more robust.

@haggit-eliyahu haggit-eliyahu changed the title Fix: resolve "import as" statements Fix: resolve "import as" statements in deconstruct flow Jan 12, 2026
@haggit-eliyahu haggit-eliyahu force-pushed the small-fix-in-imports-deconstruct branch from 688df18 to 4df4e4c Compare January 12, 2026 09:42
@haggit-eliyahu haggit-eliyahu force-pushed the small-fix-in-imports-deconstruct branch from 65efbb2 to 4349b37 Compare January 13, 2026 11:09
@TalShafir1
Copy link
Member

/gemini review

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 extends the import transformation logic to handle import ... as ... and multi-module import statements. While the added test cases cover many new scenarios, the implementation in both CorePackageImportTransformer and CorePackageInternalImportTransformer contains a critical flaw. The logic incorrectly assumes all modules on a single import line are of the same type and structure, based only on the first module. This can lead to generating invalid import statements when mixed imports are present. I've left detailed comments on the specific transformers with examples of the failing cases. These issues should be addressed, and the test suite should be expanded to include these negative test cases to ensure correctness.

@haggit-eliyahu haggit-eliyahu force-pushed the small-fix-in-imports-deconstruct branch 2 times, most recently from 9682092 to 5e2a9d6 Compare January 14, 2026 19:34
@haggit-eliyahu haggit-eliyahu force-pushed the small-fix-in-imports-deconstruct branch 2 times, most recently from cc7a2ee to 1740fe3 Compare January 19, 2026 07:57
# Conflicts:
#	packages/mp/pyproject.toml
#	packages/mp/uv.lock
@haggit-eliyahu haggit-eliyahu force-pushed the small-fix-in-imports-deconstruct branch from 1740fe3 to 48b1f10 Compare January 19, 2026 08:01
@haggit-eliyahu
Copy link
Contributor Author

/gemini review

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 effectively addresses the handling of import ... as ... statements and multi-module imports within the code transformation logic. The changes in SdkImportTransformer, CorePackageImportTransformer, and CorePackageInternalImportTransformer are robust and correctly partition and transform various import styles. The addition of leave_SimpleStatementLine to handle import statements at the line level is a smart approach to correctly split core and non-core imports. The new tests are comprehensive and cover a wide range of edge cases, which significantly improves confidence in these changes.

My review includes a couple of suggestions to improve maintainability by refactoring duplicated code and to align docstrings with the project's style guide. Overall, this is a solid improvement to the codebase.

@haggit-eliyahu haggit-eliyahu force-pushed the small-fix-in-imports-deconstruct branch from 48b1f10 to 2f096d1 Compare January 19, 2026 08:20
# Conflicts:
#	packages/mp/pyproject.toml
#	packages/mp/uv.lock
@haggit-eliyahu haggit-eliyahu force-pushed the small-fix-in-imports-deconstruct branch from 2f096d1 to 736ded9 Compare January 19, 2026 12:51
@haggit-eliyahu
Copy link
Contributor Author

/gemini review

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 significantly improves the robustness of import statement manipulation by refactoring the CST transformers to handle complex cases like multiple imports on a single line and aliased imports. A new base class BaseCoreImportTransformer is introduced to abstract common logic, which is a great design choice. The changes also fix a bug where only the first module in an import statement was being processed. Additionally, comprehensive unit tests have been added to cover these new scenarios, ensuring the changes are well-tested. The code quality is high. I have one suggestion to further improve maintainability by using Python's abc module for abstract base classes.

@haggit-eliyahu haggit-eliyahu force-pushed the small-fix-in-imports-deconstruct branch from cd69491 to e764dcb Compare January 20, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working mp mp related change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants