Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix enum strict JSON validation when validators are present #1632

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

Viicos
Copy link
Member

@Viicos Viicos commented Feb 12, 2025

Change Summary

Same as #1080. While this addresses pydantic/pydantic#11070, the issue happens in many places, as reported in pydantic/pydantic#9204. The core issue is that before/wrap validators transform the input into the Python mode. This is a a though issue to address, I don't know if it's really possible to fix it properly without making breaking changes and/or tradeoffs.

Related issue number

Fixes pydantic/pydantic#11070.

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

Copy link

codspeed-hq bot commented Feb 12, 2025

CodSpeed Performance Report

Merging #1632 will not alter performance

Comparing enum-json-strict (f7a81ac) with main (51bae7d)

Summary

✅ 157 untouched benchmarks

Copy link
Contributor

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks!

I think the ideal solution I would like to see is for what types are accepted in each of JSON / Python logic to be decided purely based on the InputType and not at all by the physical input value. But I think this would be a large-ish refactor, so it's a future idea.

@Viicos Viicos merged commit 0a467e9 into main Feb 12, 2025
28 of 29 checks passed
@Viicos Viicos deleted the enum-json-strict branch February 12, 2025 20:25
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected validation of annotated enum in strict mode
2 participants