Open jjshinobi opened 4 months ago
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 (https://github.com/godatadriven/pydantic-spark/blob/d61c660decf5745a3fc69ec386b945ddf72e5e11/src/pydantic_spark/base.py#L143). 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.