[ENG-4165] Consider default and default_factory for state vars
When determining whether a state var should be marked as optional, check that it is missing both default and default_factory and is not required. Fix #4471
This commit is contained in:
parent
49a8f813fe
commit
ce364e0bce
@ -1081,6 +1081,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|||||||
if (
|
if (
|
||||||
not field.required
|
not field.required
|
||||||
and field.default is None
|
and field.default is None
|
||||||
|
and field.default_factory is None
|
||||||
and not types.is_optional(prop._var_type)
|
and not types.is_optional(prop._var_type)
|
||||||
):
|
):
|
||||||
# Ensure frontend uses null coalescing when accessing.
|
# Ensure frontend uses null coalescing when accessing.
|
||||||
|
Loading…
Reference in New Issue
Block a user