fix(py/plugins): move in-function import to top level in google-genai#4461
fix(py/plugins): move in-function import to top level in google-genai#4461
Conversation
BackgroundAction is used at runtime, so it needs to be a regular import, not inside TYPE_CHECKING. Removes the duplicate in-function import.
Summary of ChangesHello @yesudeep, 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 linting warning by refactoring an import statement for Highlights
🧠 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. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request correctly refactors the import of BackgroundAction in py/plugins/google-genai/src/genkit/plugins/google_genai/google.py. By moving the import to the top level, it resolves a linting warning and removes the need for a local, in-function import. The change is clean, improves code readability, and follows Python best practices. I have no further suggestions.
Converts markdown and :: code blocks in docstrings to Python doctest format (>>>) to avoid false positives in in-function import checks. The remaining warning for microsoft-foundry is a legitimate try/except import for optional dependencies, which is an acceptable pattern.
1533882 to
e597b8a
Compare
Summary
Fixes in-function import warnings from
bin/lint.Changes
Real Fix: google-genai plugin
BackgroundActionimport fromTYPE_CHECKINGblock to top levelTYPE_CHECKINGbut is actually used at runtime for instantiationDocstring Fixes
Converted docstring examples from
:\:and triple-backtick markdown formats to Python doctest format (>>>) to avoid false positives in the in-function import lint check:plugins/cloudflare-workers-ai/plugin.pyplugins/google-genai/rerankers/__init__.pyplugins/google-genai/evaluators/__init__.pyplugins/huggingface/plugin.pyplugins/mcp/server.pyplugins/mistral/plugin.pyIntentional Pattern Preserved
The
microsoft-foundry/telemetry/tracing.pyimport warning is legitimate - it's a try/except import for optional dependencies (azure-monitor-opentelemetry-exporter), which is an acceptable pattern for optional dependencies.Testing
bin/check_consistencynow shows only the intentional optional dependency import