Coordinate cannot be used as optional field
lgln-kmi opened this issue · comments
Following code:
from pydantic import BaseModel
from pydantic_extra_types.coordinate import Coordinate
from typing import Optional
class A( BaseModel ):
c: Optional[ Coordinate ] = None
a = A()
cannot be run
File "pydantic_coordinate.py", line 10, in <module>
a = A()
^^^
File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 165, in __init__
__pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pydantic/_internal/_mock_val_ser.py", line 47, in __getattr__
raise PydanticUserError(self._error_message, code=self._code)
pydantic.errors.PydanticUserError: `A` is not fully defined; you should define `Latitude`, then call `A.model_rebuild()`.
Selected Assignee: @Kludex