-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this 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
andcache_eviction_hook
inplugin_cache.py
to correctly accept aRequest
object. - Example Cache Size Adjustment: I've reduced the default cache size in the
plugin_cache.py
example to1024
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
-
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. ↩
There was a problem hiding this 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.
def cache_free_hook(data: CustomizedCacheData) ->: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
def cache_eviction_hook(cache, request: Request): | |
def cache_eviction_hook(cache, _request: Request): |
No description provided.