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

Handle null #53

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Conversation

jessemyers-lettuce
Copy link
Contributor

@jessemyers-lettuce jessemyers-lettuce commented Sep 16, 2023

Related to #52, it's not clear why an explicit null converts to Any; converting to None seems more correct and will help pydantic properly parse typed object values of the form Union[Foo | None] (because with Union[Foo | Any], it doesn't seem to know what to do.

@jessemyers-lettuce
Copy link
Contributor Author

I was able to integrate this change into my own usage and it works as expected. Beyond just being more correct, it solves an issue where if Bar and Foo are both object types (with their own schemas) and Bar contains a nullable Foo, pydantic would deserialize Union[Foo, Any] as a dict (if not null) but now, correctly deserializes Union[Foo, None] as a Foo in this case.

@MarcoMuellner
Copy link
Owner

Good catch! Thank you :)

@MarcoMuellner MarcoMuellner merged commit f79bae1 into MarcoMuellner:main Sep 18, 2023
3 of 4 checks passed
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