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
A field annotated as typing.Optional[T] will be required, allowing for a value of None.
It does not mean that the field has a default value of None. (This is a breaking change from V1.)
Currently, we can only use someProperty: Optional[str] and we have to explicitly set None to the property in the object that is being validated.
The text was updated successfully, but these errors were encountered:
jjshinobi
changed the title
Optional[Type] with default value is not nullable
Optional[Type] with default value None is not nullable
Jul 3, 2024
As a workaround we use someProperty: Optional[str] = Field(default_factory=lambda: None). This repo isn't being maintained as well as, for example, https://github.com/mitchelllisle/sparkdantic, so I'd take a look there as well.
Hi,
According to https://docs.pydantic.dev/latest/migration/#required-optional-and-nullable-fields
we should be able to specify the class:
But, if we do so, the property is not nullable because it has the default value (
pydantic-spark/src/pydantic_spark/base.py
Line 143 in d61c660
Note from the
pydantic
docs:Currently, we can only use
someProperty: Optional[str]
and we have to explicitly setNone
to the property in the object that is being validated.The text was updated successfully, but these errors were encountered: