Skip to content

Conversation

@rickeylev
Copy link
Collaborator

While reading hub_builder.bzl, I had to track down a lot of source to figure out
what variables were tracking what.

Add various comments to describe variable types and their purpose.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rickeylev, 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 significantly improves the readability and maintainability of the hub_builder.bzl and extension.bzl files by introducing extensive type information and documentation comments. The changes aim to make it easier for developers to understand the purpose and structure of various variables and function arguments, reducing the need for deep source code tracing and enhancing overall code comprehension.

Highlights

  • Improved Type Information for pip_hub_map: Added a type hint comment for the pip_hub_map variable in extension.bzl, clarifying its structure as dict[str repo, HubBuilder].
  • Enhanced hub_builder Variable Documentation: Introduced comprehensive type hint comments for numerous internal variables within the hub_builder function in hub_builder.bzl, significantly improving the understanding of their data structures and purpose.
  • Clarified _build Function Return Structure: Enhanced the _build function's return struct with explicit type comments for its fields, such as whl_map, group_map, extra_aliases, exposed_packages, and whl_libraries, providing clearer expectations for its output.
  • Added Docstrings to Setter Functions: Incorporated detailed docstrings, including argument types, for setter functions like _add_exposed_packages, _add_group_map, _add_extra_aliases, and _add_whl_library, thereby improving the API documentation and usability of these functions.

🧠 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 is a great initiative to improve code readability by adding type information in comments. I've found a few instances where the added type hints appear to be incorrect. My review includes suggestions to correct these, ensuring the documentation is accurate and helpful. The rest of the changes look good.

# The nested dict is a dict acting as a set.
# dict[str whl_name, dict[str alias_name, bool]]
_extra_aliases = {}, # modified by _add_extra_aliases
# dict[str whl_name, list[str]]
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 type hint for _group_map seems to be incorrect. Based on its usage in _add_group_map, the keys are group names, not wheel names. The type should be dict[str group_name, list[str]].

        # dict[str group_name, list[str]]

_whl_libraries = {}, # modified by _add_whl_library
# Map of repos and their config settings, and repo the config
# setting originated from.
# dict[str repo_name, dict[str config_setting, str repo_name]]
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 type hint for _whl_map appears to be incorrect. In _add_whl_library, the first key is whl.name, which is the wheel name, not repo_name. The type should be dict[str whl_name, dict[str config_setting, str repo_name]].

        # dict[str whl_name, dict[str config_setting, str repo_name]]


return struct(
# The config settings for matching repo spokes.
# dict[str repo_name, dict[str repo_name, list[str]]]
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 type hint for the returned whl_map seems incorrect. The code that constructs it uses the wheel name as the primary key. The type should be dict[str whl_name, dict[str repo_name, list[str]]].

        # dict[str whl_name, dict[str repo_name, list[str]]]

Comment on lines +132 to +133
# Maps a wheel to a list of groups
# dict[str whl_name, list[str]]
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 description and type hint for group_map appear to be inverted. self._group_map maps a group name to a list of wheel names. The comment should reflect this.

        # Maps a group to a list of wheels
        # dict[str group_name, list[str]]

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