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
fix: support pydantic.Field(kw_only=True)
with inherited dataclasses
#7827
Conversation
2069ae8
to
3115135
Compare
except AttributeError: | ||
# no default value has been set for this field | ||
continue | ||
if isinstance(field_value, FieldInfo) and field_value.kw_only: |
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.
For now I went with the smallest change possible instead of wrapping them all the time and forward other stuff like init
. I suggest we wait to see if this method needs to more than that
please review |
Thanks @PrettyWood for this patch 🙏 It looks good to me 👍 Let's see @dmontagu opinion here. |
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.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.
LGTM, and @dmontagu said he approved of the changes as well.
@PrettyWood as you mentioned here, I think it's worth us revisiting this new functionality and seeing if we should account for other things like init
, etc.
Change Summary
pydantic dataclasses support
pydantic.Field
and also supportkw_only
parameter.But when we set
pydantic.Field(kw_only=True)
as value of a field, the stdlib dataclass behind the scene would use a field without the option causing some differences with the usage of pure stdlib dataclasses.Related issue number
closes #7770
Checklist
Selected Reviewer: @hramezani