Skip to content

fix: access model fields via class #2146

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

emmanuel-ferdman
Copy link
Contributor

PR Summary

This small PR updates the usage of field metadata access to align with the Pydantic V2 API and resolve Pydantic deprecation warnings, as seen in the CI logs:

PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 28, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR addresses a Pydantic V2 deprecation warning by updating how model fields are accessed in the update_strings utility function. The change modifies line 52 in ragas/src/ragas/prompt/utils.py from new_obj.model_fields to new_obj.__class__.model_fields, switching from the deprecated instance-based field access to the recommended class-based approach.

This fix aligns with Pydantic V2.11+ API requirements, where accessing model_fields directly on instances has been deprecated in favor of accessing it through the model class. The update_strings function appears to be a utility that recursively processes Pydantic model fields to update string values, making proper field access essential for its operation.

The change is part of maintaining compatibility with evolving Pydantic versions, as the deprecated functionality will be completely removed in Pydantic V3.0. This update ensures the codebase remains future-proof while eliminating warning noise from CI builds.

Confidence score: 5/5

  • This is an extremely safe change that simply updates deprecated API usage to the current standard
  • High confidence because it's a direct API migration with no functional changes, addressing a clear deprecation warning
  • No files need additional attention - this is a minimal, well-targeted fix

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@emmanuel-ferdman
Copy link
Contributor Author

@shahules786 could you please review this small PR when you get the chance? thanks 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant