Behaviour of Partial for objects with nullable types
#613
Closed
peterschutt
started this conversation in
Potential Issues
Replies: 2 comments
|
There is another side to the issue as well. As we make all the types This is what I think we need for a proper
I think this can be solved by using a sentinel that is not a valid json type. It would be breaking, but I'm not sure how useful the current implementation is with these limitations anyway. |
0 replies
|
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
TypedDictanddataclasshave a slight difference in behavior when used withPartial. Omitted properties are excluded forTypedDict, while fordataclassthey are set toNone.{}{"a":null,"b":null,"c":null}{"c": null}{"a":null,"b":null,"c":null}{}{}{"c": null}{"c": null}The
TypedDictbehavior is advantageous as can discern when a nullable property has been explicitly set to null or not. However, a dataclass instance cannot be constructed without values for all attributes, so maybe some sort of sentinel default value is necessary for that case.All reactions