Skip to content

Conversation

@kafkas
Copy link
Member

@kafkas kafkas commented Dec 3, 2025

Description

Adds UncheckedBaseModel.model_validate to de-alias the input object with convert_and_respect_annotation_metadata before passing it to Pydantic, so JSON keys defined via FieldMetadata(alias=...) map to their Python attributes as expected.

Changes Made

  • Added the model_validate method to UncheckedBaseModel

Testing

  • Unit tests added/updated
  • Manual testing completed

Note

Override UncheckedBaseModel.model_validate (Pydantic v2) to de-alias input via convert_and_respect_annotation_metadata before validation.

  • Python core utilities:
    • UncheckedBaseModel (Pydantic v2):
      • Add model_validate override to pre-process inputs with convert_and_respect_annotation_metadata (respects FieldMetadata aliases) before delegating to Pydantic.
    • Serialization:
      • Import convert_and_respect_annotation_metadata alongside get_field_to_alias_mapping.

Written by Cursor Bugbot for commit f1d34fb. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI
  • Postman

How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR.

@fern-support fern-support force-pushed the anar/python-pydantic-v2-alias-decoding branch from f1d34fb to 49c2919 Compare December 3, 2025 10:42
@kafkas kafkas merged commit dad2b7b into main Dec 3, 2025
126 checks passed
@kafkas kafkas deleted the anar/python-pydantic-v2-alias-decoding branch December 3, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants