-
Notifications
You must be signed in to change notification settings - Fork 699
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
This library is using a deprecated Pydantic pattern, which raises a deprecation warning since Pydantic 2.12.3 and an error on Pydantic 2.12.0->2.12.2.
The deprecation warning is PydanticDeprecatedSince212: Using '@model_validator' with mode='after' on a classmethod is deprecated.
The deprecated pattern can be found in google/genai/types.py within the Metric class:
@model_validator(mode='after') # type: ignore[arg-type]
@classmethod
def validate_name(cls, model: 'Metric') -> 'Metric':
if not model.name:
raise ValueError('Metric name cannot be empty.')
model.name = model.name.lower()
return modelThis code should be:
@model_validator(mode='after')
def validate_name(self) -> 'Metric':
if not self.name:
raise ValueError('Metric name cannot be empty.')
self.name = self.name.lower()
return modelThe issue is very similar to the one reported in apache/iceberg-python#2590 and solved via apache/iceberg-python#2626. There you can find more context on the issue itself.
I could easily open a PR to fix this but the header of the file says Code generated by the Google Gen AI SDK generator DO NOT EDIT. so it seems editing it directly is not permitted.
Environment details
- Programming language: Python
- OS: Ubuntu
- Language runtime version: 3.14
- Package version: 1.46.0 (also on older versions)
Steps to reproduce
- Have an installation with Pydantic >= 2.12 (2.12.3 for a deprecation warning instead of an error)
- (example) import google.genai types
from google.genai import types as genai_types
marton-uic, andreasoprani and jamesyoung-15
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.