Skip to content

Commit 890129f

Browse files
committed
Fix Pydantic v2 compatibility and address PR review feedback
- Fix critical bug in GenericAlias handler calling (handler is callable, not object with generate_schema method) - Completely rewrite test_pydantic_v2_compatibility.py to address all PR feedback: - Remove invalid imports of nested functions (__get_pydantic_core_schema__) - Fix assertion mismatches (OpenAPI version 3.1.0, correct API title) - Restructure tests to validate patching mechanism itself - Fix handler mocking to treat handlers as callables - Add comprehensive behavior tests with proper classmethod calling - All 17 tests now pass with full coverage of patching scenarios - Address types.GenericAlias immutability issues in tests - Improve error handling and fallback validation
1 parent b1c8878 commit 890129f

File tree

2 files changed

+279
-157
lines changed

2 files changed

+279
-157
lines changed

src/google/adk/utils/pydantic_v2_compatibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def generic_alias_get_pydantic_core_schema(cls, source_type, handler):
7676
if hasattr(source_type, "__origin__") and hasattr(source_type, "__args__"):
7777
try:
7878
# Let pydantic handle the origin type (list, dict, etc.)
79-
return handler.generate_schema(source_type.__origin__)
79+
return handler(source_type.__origin__)
8080
except Exception:
8181
# Fallback to any schema if we can't handle the specific type
8282
return core_schema.any_schema()

0 commit comments

Comments
 (0)