Skip to content

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 <[email protected]>
@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

Copy link
Contributor

@anistark anistark left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @emmanuel-ferdman 🎉

However the type checks are failing. Could you please rebase and run make run-ci locally once?

@anistark
Copy link
Contributor

Thanks @emmanuel-ferdman

@anistark anistark merged commit fed32ea into explodinggradients:main Aug 20, 2025
8 of 9 checks passed
ahgraber pushed a commit to ahgraber/ragas that referenced this pull request Aug 26, 2025
## 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](https://github.com/explodinggradients/ragas/actions/runs/16534007312/job/46765109247#step:8:56):
```python
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 <[email protected]>
NirantK pushed a commit to NirantK/ragas-upgrades that referenced this pull request Sep 1, 2025
## 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](https://github.com/explodinggradients/ragas/actions/runs/16534007312/job/46765109247#step:8:56):
```python
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 <[email protected]>
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.

2 participants