-
Notifications
You must be signed in to change notification settings - Fork 657
fix(py): clean up in-function imports in core framework #4400
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
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 significantly enhances the Python codebase hygiene within the Genkit framework by systematically addressing 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. 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
|
67f2ba0 to
c3db14b
Compare
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 does a good job of cleaning up in-function imports to adhere to PLC0415 (import at top-level). Most of the changes correctly move imports to the top of the file or add noqa directives for valid exceptions like optional dependencies. However, I've found one critical issue in py/packages/genkit/src/genkit/core/_plugins.py where removing an import breaks the plugin discovery mechanism. Please see the detailed comment for the fix.
48f0fdb to
6b5d7f1
Compare
6b5d7f1 to
0d47a28
Compare
|
/gemini review |
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 provides a solid cleanup of in-function imports, moving them to the top level to address PLC0415 violations. The changes are applied consistently across the core framework and test files. The cases where imports remain within functions for lazy loading or to prevent circular dependencies are correctly handled with noqa directives and clear comments. This refactoring improves code quality and readability without introducing any issues. Great work!
The core framework has some intentional in-function imports for lazy loading and circular import avoidance. These are being cleaned up in PR #4400. Until that PR is merged, exclude packages/genkit from the in-function imports check to avoid CI failures. The check now only scans plugins/*/src/ for in-function imports.
Move imports to module top-level or add noqa comments for intentional deferred imports (uvloop optional loading, lazy server adapter imports, circular import avoidance). Changes: - packages/genkit/src: Move exports to top, add noqa for lazy imports - packages/genkit/tests: Move test imports to module level Related to #4398
0d47a28 to
13ff01f
Compare
Summary
Clean up PLC0415 (import at top-level) violations in the core Genkit framework.
Changes
packages/genkit/src/genkit/ai/_aio.pypackages/genkit/src/genkit/ai/_registry.pypackages/genkit/src/genkit/aio/loop.pypackages/genkit/src/genkit/blocks/background_model.pypackages/genkit/src/genkit/blocks/session/session.pypackages/genkit/src/genkit/core/_plugins.pypackages/genkit/src/genkit/core/plugin.pypackages/genkit/src/genkit/core/trace/default_exporter.pypackages/genkit/src/genkit/web/manager/_adapters.pypackages/genkit/tests/Related
Test Plan