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
The TColumnType present in the dlt.common.schema module cannot be used as a property within a Pydantic model for Python versions before 3.12. The reason being is that TColumnType inherits from TypedDict, but that comes from the typing module. Python versions prior to 3.12 do not support this. The TypedDict type lives in the typing_extensions module.
As such, Pydantic fails to create a model.
pydantic.errors.PydanticUserError: Please use `typing_extensions.TypedDict` instead of `typing.TypedDict` on Python < 3.12.
Expected behavior
Expected behaviour is to change all imports of TypedDict to something like
This would allow the usage of the very nice schema types that dlt exposes in custom Pydantic models.
Steps to reproduce
Create a simple type that inherits from pydantic.BaseModel and add a property of TColumnType in a Python interpreter that is running a version older than 3.12. Try to instantiate your model and see that it fails.
Operating system
macOS
Runtime environment
Local
Python version
3.11
dlt data source
No response
dlt destination
No response
Other deployment details
No response
Additional information
No response
The text was updated successfully, but these errors were encountered:
hmmm TypedDict is in typing from 3.8... most probably Pydantic needs some features that were not implemented before 3.12. We had the same issues with Annotated which is now imported via extensions. @sh-rp we import all such typings via dlt.common.typing (or at least we should) so let's import it there and then from there evrywhere else
dlt version
1.4.0
Describe the problem
The
TColumnType
present in thedlt.common.schema
module cannot be used as a property within a Pydantic model for Python versions before 3.12. The reason being is thatTColumnType
inherits fromTypedDict
, but that comes from thetyping
module. Python versions prior to 3.12 do not support this. TheTypedDict
type lives in thetyping_extensions
module.As such, Pydantic fails to create a model.
Expected behavior
Expected behaviour is to change all imports of
TypedDict
to something likeThis would allow the usage of the very nice schema types that dlt exposes in custom Pydantic models.
Steps to reproduce
Create a simple type that inherits from
pydantic.BaseModel
and add a property ofTColumnType
in a Python interpreter that is running a version older than 3.12. Try to instantiate your model and see that it fails.Operating system
macOS
Runtime environment
Local
Python version
3.11
dlt data source
No response
dlt destination
No response
Other deployment details
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: