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

Remove smart union from Generic #95

Merged
merged 8 commits into from Apr 1, 2022
Merged

Remove smart union from Generic #95

merged 8 commits into from Apr 1, 2022

Conversation

oscarbc96
Copy link
Contributor

By default, pydantic tries to validate (and coerce if it can) in the order of the Union. If smart_union is enabled. Pydantic will then check all allowed types before even trying to coerce. This is of course slower, especially if your Union is quite big which is our case.

Our Union is ordered to always coerce to the first possible option, so we don't need the smart union.
Also, this order in combination of the smart_union flag (which was trying to not coerce), was making that booleans like 'true' and 'false' not being converted to bools

@oscarbc96 oscarbc96 marked this pull request as ready for review April 1, 2022 05:25
Copy link
Member

@w0rmr1d3r w0rmr1d3r left a comment

Choose a reason for hiding this comment

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

Good job! Some small additions before is ready

CHANGELOG.md Outdated Show resolved Hide resolved
tests/test_generic.py Show resolved Hide resolved
@oscarbc96 oscarbc96 requested a review from w0rmr1d3r April 1, 2022 08:21
Copy link
Member

@w0rmr1d3r w0rmr1d3r left a comment

Choose a reason for hiding this comment

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

Perfect! 🚀

@oscarbc96 oscarbc96 merged commit 4fa1d9e into master Apr 1, 2022
@w0rmr1d3r w0rmr1d3r deleted the remove_smart_union branch September 23, 2022 08:26
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

3 participants