Skip to content

Fix: signature error in plugin example #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025
Merged

Fix: signature error in plugin example #11

merged 1 commit into from
Jul 28, 2025

Conversation

haochengxia
Copy link
Collaborator

No description provided.

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.

Summary of Changes

Hello @haochengxia, 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 addresses a signature error in the plugin example by updating the Python hook function definitions and their corresponding documentation. It also adjusts cache sizes in the example for potentially better demonstration or testing.

Highlights

  • Documentation Update: I've added explicit signature requirements for Python cache hook functions in the plugin.md documentation.
  • Hook Signature Correction: I've corrected the signatures of cache_hit_hook and cache_eviction_hook in plugin_cache.py to correctly accept a Request object.
  • Example Cache Size Adjustment: I've reduced the default cache size in the plugin_cache.py example to 1024 for both the plugin and reference LRU caches.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 or fill out our survey to provide feedback.

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.

@haochengxia haochengxia merged commit 5f15031 into main Jul 28, 2025
34 checks passed
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 fixes signature errors in the plugin example and updates the documentation accordingly. The changes in the example code correctly align the hook function signatures with the plugin system's expectations. I've found a couple of minor issues in the documentation and a small style improvement for the example code. Specifically, there are syntax errors in the type hints in plugin.md, and an unused parameter in plugin_cache.py could be marked as such for clarity. Overall, this is a good fix.

Comment on lines +25 to +26
def cache_free_hook(data: CustomizedCacheData) ->: ...
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There are syntax errors in the return type annotations for cache_remove_hook and cache_free_hook. The trailing colon ->: is invalid. Based on the example implementation, these functions do not return a value, so the return type should be None.

Suggested change
def cache_remove_hook(data: CustomizedCacheData, obj_id: int | str) ->: ...
def cache_free_hook(data: CustomizedCacheData) ->: ...
def cache_remove_hook(data: CustomizedCacheData, obj_id: int | str) -> None: ...
def cache_free_hook(data: CustomizedCacheData) -> None: ...


def cache_miss_hook(cache, request: Request):
cache.cache_miss(request.obj_id, request.obj_size)

def cache_eviction_hook(cache):
def cache_eviction_hook(cache, request: Request):
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 request parameter is unused in this function. To improve code clarity and signal that this is intentional, it's a good practice in Python to prefix unused parameters with an underscore.

Suggested change
def cache_eviction_hook(cache, request: Request):
def cache_eviction_hook(cache, _request: Request):

@haochengxia haochengxia deleted the hxia/plugin branch July 28, 2025 04:33
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