Skip to content

fix: access model_fields from class instead of instance#663

Open
sene03 wants to merge 1 commit intoapache:mainfrom
sene03:fix/update-pydantic-model-fields-usage
Open

fix: access model_fields from class instead of instance#663
sene03 wants to merge 1 commit intoapache:mainfrom
sene03:fix/update-pydantic-model-fields-usage

Conversation

@sene03
Copy link

@sene03 sene03 commented Feb 17, 2026

Fixes deprecation warning in Pydantic 2.11+ where accessing model_fields on an instance is deprecated. Changed to use type(model).model_fields in model_to_dict().

Closes #652

Changes

How I tested this

Notes

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future TODOs are captured in comments
  • Project documentation has been updated if adding/changing functionality.

Fixes deprecation warning in Pydantic 2.11+ where accessing
model_fields on an instance is deprecated. Changed to use
type(model).model_fields in model_to_dict().

Closes apache#652

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@skrawcz
Copy link
Contributor

skrawcz commented Mar 1, 2026

@sene03 I think we need a minimum version pin in pyproject.toml with this change -- do you know what that would be?

@skrawcz
Copy link
Contributor

skrawcz commented Mar 3, 2026

you need to pair this with #654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update pydantic usage before 3.0

2 participants