-
Notifications
You must be signed in to change notification settings - Fork 76
Add unset field semantics for structs ("strict structs") #607
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
Conversation
Signed-off-by: Simon Beyzerov <simon.beyzerov@point72.com>
…ance bug Signed-off-by: Adam Glustein <adam.glustein@point72.com>
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
|
Previously, when all fields on structs were optional, we hard-coded these two flags for pydantic validation
Can we only apply this logic when |
I tested out this approach and it doesn't validate correctly in the case of a required field with a default value. class MyStrictStruct(csp.Struct, allow_unset=False):
req_default_str: str = "default" |
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
I think this just means that if there is a default value, we leave it as "optional" (as the user doesn't have to provide it), but if there isn't, then it's not. I guess I was wrong about pydantic inferring it. However, the behavior for non-defaulted fields will be different for the two types of Struct. |
…ield is set to None in the struct's bitmask Signed-off-by: Adam Glustein <adam.glustein@point72.com>
b86157d to
c343b5a
Compare
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
… test Signed-off-by: Adam Glustein <adam.glustein@point72.com>
1a22aba to
89ba9d0
Compare
I am not sure what you mean by this. In the semantics of structs, |
robambalu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks gtg, lets wait on Pascal for that open conversation though
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
Added logic to require fields without a default value in the case of a strict struct: 80f26d3 |
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
Cleanup and a few fixes to #574, thanks @sim15 for the contribution!