-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
BaseModel.construct returns instances with None assigned to fields with a default_factory #1732
Comments
None
assigned to fields with a default_factory
Hi @zoopp,
|
Thank you for the reply @PrettyWood, It's okay, I can work around the issue until a consensus is reached on what the behavior should be. Speaking from my point of view, or more generally from a user of the library's point of view, I would say it would make sense that if Would it make sense to call the factories inside the |
@zoopp I'll try to work on this bug soon. I agree the behaviour should be the same as calling |
@zoopp I opened a PR with a proposal to support |
I looked over the PR and from my point of view it seems well done. I've tested your fix in my application as well and things work without any issues. Awesome job! 👍 |
* feat: support `default_factory` with `BaseModel.construct` closes #1732 * refactor: remove __field_defaults__ * docs: update change with `__field_defaults__` deletion
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:Hello, I'm using pydantic in an application and after updating to v1.6.1 from v1.5.1 I came across this situation which results in a couple of failures.
From the changelog and documentation it's not clear if this change was intended or not.
The text was updated successfully, but these errors were encountered: