Skip to content

Conversation

@yesudeep
Copy link
Contributor

@yesudeep yesudeep commented Jan 25, 2026

fix(py): fix test failures and enforce type checking in CI

This commit addresses test failures caused by type annotation fixes and
enables strict type checking in CI.

CI Enforcement:

  • Remove --exit-zero from uv ty check in python.yml to fail CI on
    type errors

Bug Fixes:

  • Fix MCP server read_resource to convert AnyUrl to str before passing
    to resource actions (server.py)
  • Add callable() check for action.matches in find_matching_resource
    to prevent NoneType errors with dynamic action providers (resource.py)

Test Expectation Updates:

  • Update schema expectations for nullable types to use anyOf format
    instead of simple type field (Pydantic v2 behavior for int | None)
    • veneer_test.py: 10 test expectations
    • schema_test.py: 1 test expectation

Type Annotation Fixes:

  • Fix incorrect nullable type annotations across plugins:
    • value: int = None -> value: int | None = None
    • Updates to Ollama, Vertex-AI, Google-GenAI, Anthropic, MCP,
      compat-oai, DeepSeek, xAI plugins and core genkit packages

Context:
Pydantic v2 generates {"anyOf": [{"type": "integer"}, {"type": "null"}]}
for int | None fields, while the old incorrect annotations int = None
produced {"type": "integer"}. This commit updates all test expectations
to match the correct schema output.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 systematically refines the Python codebase by focusing on type correctness and consistency. It introduces explicit type hints, updates data structures to leverage Pydantic models and enums, and standardizes API interactions across various plugins. The changes aim to make the code more robust, maintainable, and easier to understand for developers by reducing ambiguity in data types and function signatures.

Highlights

  • Enhanced Type Safety and Consistency: Significant updates across multiple Python packages and plugins to improve type checking and type safety. This includes migrating from generic dictionaries to more specific Pydantic models, enums, and typing module constructs like Union and cast.
  • Dependency and Package Management: The uvloop dependency has been added for non-Windows platforms in the core genkit package. The genkit-plugins-mcp package has been renamed to genkit-plugin-mcp for consistency across the project.
  • Refactored API Integrations: Various plugins (MCP, Google GenAI, Ollama, Vertex AI, xAI) have seen their API integration logic refined. This includes more robust handling of model responses, improved schema conversions, and clearer client initialization, especially for streaming and tool-use scenarios.
  • Improved Resource and Metric Handling: Changes in the Firebase and Google Cloud plugins enhance how resources are converted and how metrics are cached, leading to more precise data handling and better performance monitoring.

🧠 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 introduces a comprehensive set of fixes to improve type checking and overall code robustness across the Python codebase. The changes are of high quality and include replacing magic strings with enums, adding assertions and None checks for better type safety, refactoring for clarity and maintainability, and updating tests to use real objects instead of mocks. These modifications significantly enhance the reliability and maintainability of the code. I have one minor suggestion regarding environment variable handling in a sample file to improve consistency.

@yesudeep yesudeep force-pushed the yesudeep/fix/needless-trousers branch 17 times, most recently from 1bae451 to 0ad182f Compare January 25, 2026 05:55
@yesudeep yesudeep changed the title yesudeep/fix/needless trousers fix(py/genkit): ty check fixes for additional cases Jan 25, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/needless-trousers branch from 0ad182f to ff6efef Compare January 25, 2026 06:15
@yesudeep yesudeep changed the title fix(py/genkit): ty check fixes for additional cases fix(py/genkit): zero lint diagnostics Jan 25, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/needless-trousers branch from ff6efef to 6af87a8 Compare January 25, 2026 06:21
@yesudeep yesudeep force-pushed the yesudeep/fix/needless-trousers branch 3 times, most recently from 1f82369 to aa8d4a3 Compare January 25, 2026 06:55
@yesudeep
Copy link
Contributor Author

/gemini review

@yesudeep yesudeep changed the title fix(py/genkit): zero lint diagnostics fix(py): fix test failures and enforce type checking in CI (zero lint) Jan 25, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/needless-trousers branch from aa8d4a3 to e4061a9 Compare January 25, 2026 06:57
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 introduces a wide range of fixes to address linting and type-checking diagnostics across the Python codebase. The changes significantly improve type safety and code robustness by adding explicit None checks, replacing string literals with enum members, updating Pydantic models to modern standards, and using stricter types. The tests have also been updated to reflect these changes, using real type instances instead of mocks, which is a great improvement. I've identified a couple of instances where type errors were silenced instead of being fixed and have provided suggestions for the correct implementation.

@yesudeep yesudeep changed the title fix(py): fix test failures and enforce type checking in CI (zero lint) fix(py): fix test failures and enforce type checking in CI (zero lint except samples) Jan 25, 2026
@yesudeep yesudeep force-pushed the yesudeep/fix/needless-trousers branch from e4061a9 to c88f8c6 Compare January 25, 2026 07:00
This commit addresses test failures caused by type annotation fixes and
enables strict type checking in CI.

CI Enforcement:
- Remove --exit-zero from uv ty check in python.yml to fail CI on
  type errors

Bug Fixes:
- Fix MCP server read_resource to convert AnyUrl to str before passing
  to resource actions (server.py)
- Add callable() check for action.matches in find_matching_resource
  to prevent NoneType errors with dynamic action providers (resource.py)

Test Expectation Updates:
- Update schema expectations for nullable types to use anyOf format
  instead of simple type field (Pydantic v2 behavior for int | None)
  - veneer_test.py: 10 test expectations
  - schema_test.py: 1 test expectation

Type Annotation Fixes:
- Fix incorrect nullable type annotations across plugins:
  - value: int = None -> value: int | None = None
  - Updates to Ollama, Vertex-AI, Google-GenAI, Anthropic, MCP,
    compat-oai, DeepSeek, xAI plugins and core genkit packages

Context:
Pydantic v2 generates {"anyOf": [{"type": "integer"}, {"type": "null"}]}
for int | None fields, while the old incorrect annotations int = None
produced {"type": "integer"}. This commit updates all test expectations
to match the correct schema output.
@yesudeep yesudeep force-pushed the yesudeep/fix/needless-trousers branch from c88f8c6 to 1d16a39 Compare January 25, 2026 07:02
@yesudeep yesudeep enabled auto-merge (squash) January 25, 2026 07:04
@yesudeep yesudeep disabled auto-merge January 25, 2026 07:06
@yesudeep yesudeep enabled auto-merge (squash) January 25, 2026 07:07
@yesudeep yesudeep disabled auto-merge January 25, 2026 07:08
@yesudeep yesudeep merged commit df9d11a into main Jan 25, 2026
22 checks passed
@yesudeep yesudeep deleted the yesudeep/fix/needless-trousers branch January 25, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants