-
Notifications
You must be signed in to change notification settings - Fork 67
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
Improve Support for Default Dataclass Fields #726
Conversation
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
fdea0f7
to
a5ae46e
Compare
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
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.
This is some nice surgery to make the @dataclass
behavior more canonical. Since it's deep in the guts, I've got a couple of places I'd like clarifying comments, but otherwise I think this will be a nice improvement!
Signed-off-by: Michael Honaker <Michael.Honaker@ibm.com>
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.
This looks great, thanks @HonakerM!
setattr(cls, annotation, dataclass_defined_default) | ||
defined_default = dataclass_defined_default | ||
|
||
if isinstance(defined_default, Callable): |
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.
Nice!
What this PR does / why we need it:
This PR improves the way Caikit handles default fields in 2 main ways. The first is to always honoring dataclass default/default_factory fields while the second is improved visibility in the openapi generation.
Special notes for your reviewer:
I discovered a bug in the vectors code where the vectors assumed default value would be
None
instead of thelist
defined in the factoryIf applicable: