Skip to content
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

Add support for extra keys validation for model fields #1671

Merged
merged 1 commit into from
Mar 20, 2025

Conversation

Viicos
Copy link
Member

@Viicos Viicos commented Mar 18, 2025

Change Summary

Part of pydantic/pydantic#9400.

This is only implemented for model fields but this could be done for dataclass/typed dict as well. I only went with models for now as it is the only data type where extra validation can be customized through __pydantic_extra__.

This also only implements validation support. Extra values can have serialization customized but I don't think we should also allow serialization customization for extra keys as we don't have such a concept for "normal" field names.

Related issue number

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Sorry, something went wrong.

@Viicos Viicos requested a review from davidhewitt March 18, 2025 11:51
Copy link

codspeed-hq bot commented Mar 18, 2025

CodSpeed Performance Report

Merging #1671 will not alter performance

Comparing extra-keys-validation (651657c) with main (ac17f0c)

Summary

✅ 157 untouched benchmarks

@Viicos Viicos merged commit f256531 into main Mar 20, 2025
29 checks passed
@Viicos Viicos deleted the extra-keys-validation branch March 20, 2025 13:35
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.

None yet

2 participants