You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
There is no way to require a field that is of type Optional, because dacite gives it a default value (i.e. None) automatically. See https://github.com/konradhalas/dacite#optional-fields
Describe the solution you'd like
A way to configure dacite to require fields which have an Optional type.
Describe alternatives you've considered
I cannot think of a workaround to get a DefaultValueNotFoundError when converting a dictionary that has missing fields of an Optional type.
Additional context
It feels like dacite should provide a mechanism to distinguish between these two dataclasses. Currently they both behave the same way and this is inconsistent compared to dataclasses where the fields are not of Optional type.
@dataclass
class MyRequiredFieldsThatMayHaveValueNone:
name: str | None
@dataclass
class MyOptionsFieldsThatByDefaultHaveValueNone:
name: str | None = None
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
There is no way to require a field that is of type Optional, because dacite gives it a default value (i.e. None) automatically. See https://github.com/konradhalas/dacite#optional-fields
Describe the solution you'd like
A way to configure dacite to require fields which have an Optional type.
Describe alternatives you've considered
I cannot think of a workaround to get a DefaultValueNotFoundError when converting a dictionary that has missing fields of an Optional type.
Additional context
It feels like dacite should provide a mechanism to distinguish between these two dataclasses. Currently they both behave the same way and this is inconsistent compared to dataclasses where the fields are not of Optional type.
The text was updated successfully, but these errors were encountered: