Skip to content

Fix condition before using prebuilt validator/serializer #1625

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

Merged
merged 2 commits into from
Feb 6, 2025
Merged

Conversation

Viicos
Copy link
Member

@Viicos Viicos commented Feb 6, 2025

Change Summary

Follow up on #1616.

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

Copy link

codspeed-hq bot commented Feb 6, 2025

CodSpeed Performance Report

Merging #1625 will not alter performance

Comparing prebuilt-td (3059474) with main (f7fb50b)

Summary

✅ 157 untouched benchmarks

// However, we don't want to use a prebuilt structure from dataclasses if we have a `generic_origin`
// as this means the dataclass was parametrized (so a generic alias instance), and `cls` in the
// core schema is still the (unparametrized) class, meaning we would fetch the wrong validator/serializer.
if (type_ != "model") || (type_ == "dataclass" && schema.contains(intern!(py, "generic_origin"))?) {
Copy link
Contributor

@davidhewitt davidhewitt Feb 6, 2025

Choose a reason for hiding this comment

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

type_ != "model" will always be True for type == "dataclass", so I think the new boolean logic here is wrong?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, seems like it is wrong on main as well, I'll fix it

@Viicos Viicos changed the title Do not check for 'typed-dict' schemas for prebuilt validator/serializer Fix condition before using prebuilt validator/serializer Feb 6, 2025
@Viicos Viicos merged commit 9446588 into main Feb 6, 2025
27 of 28 checks passed
@Viicos Viicos deleted the prebuilt-td branch February 6, 2025 15:45
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.

3 participants