fix lazy init calling default factory
If no default factory is set the value is actually some internal sentinel object (dataclasses._MISSING_VALUE) instead of something falsy like `None`.
This commit is contained in:
parent
b0832b8659
commit
57cfd8f496
1 changed files with 1 additions and 1 deletions
|
|
@ -195,7 +195,7 @@ class Movie:
|
||||||
return
|
return
|
||||||
|
|
||||||
for field in fields(Movie):
|
for field in fields(Movie):
|
||||||
if getattr(self, field.name) is None and field.default_factory:
|
if getattr(self, field.name) is None and callable(field.default_factory):
|
||||||
setattr(self, field.name, field.default_factory())
|
setattr(self, field.name, field.default_factory())
|
||||||
|
|
||||||
self._is_lazy = False
|
self._is_lazy = False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue