From c6c72778741c3559fd80a34eb95a00e956938144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Portela=20Afonso?= Date: Mon, 3 Feb 2025 21:45:24 +0000 Subject: [PATCH] fix: pydantic and typeguard (#153) * fix: pydantic and typeguard * fix(linting): code formatting --------- Co-authored-by: Azory YData Bot --- pyproject.toml | 2 +- src/ydata/sdk/common/model.py | 10 +++++----- src/ydata/sdk/connectors/_models/schema.py | 13 +++++-------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a4b5e061..67896aec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ dependencies = [ "pandas>=1.5.0", "prettytable==3.13.*", "pydantic>=2.0.0", - "typeguard>=4.0.0", + "typeguard==2.13.3", "ydata-datascience" ] diff --git a/src/ydata/sdk/common/model.py b/src/ydata/sdk/common/model.py index cb286263..bd11b14a 100644 --- a/src/ydata/sdk/common/model.py +++ b/src/ydata/sdk/common/model.py @@ -1,10 +1,10 @@ from pydantic import BaseModel as PydanticBaseModel -from pydantic import Extra +from pydantic import ConfigDict -class Config: - allow_population_by_field_name = True - extra = Extra.ignore +class Config(ConfigDict): + populate_by_name = True + extra = 'allow' use_enum_values = True @@ -13,4 +13,4 @@ class BaseModel(PydanticBaseModel): All datamodel from YData SDK inherits from this class. """ - Config = Config + model_config = Config() diff --git a/src/ydata/sdk/connectors/_models/schema.py b/src/ydata/sdk/connectors/_models/schema.py index e8696e91..5a8768ef 100644 --- a/src/ydata/sdk/connectors/_models/schema.py +++ b/src/ydata/sdk/connectors/_models/schema.py @@ -2,16 +2,17 @@ from pydantic import Field -from ydata.sdk.common.model import BaseModel +from ydata.sdk.common.model import BaseModel, Config from ydata.sdk.common.pydantic_utils import to_camel -class BaseConfig(BaseModel.Config): +class BaseConfig(Config): alias_generator = to_camel class TableColumn(BaseModel): """Class to store the information of a Column table.""" + model_config = BaseConfig() name: str variable_type: str # change this to the datatypes @@ -20,24 +21,20 @@ class TableColumn(BaseModel): foreign_keys: list nullable: bool - Config = BaseConfig - class Table(BaseModel): """Class to store the table columns information.""" + model_config = BaseConfig() name: str columns: List[TableColumn] primary_keys: List[TableColumn] foreign_keys: List[TableColumn] - Config = BaseConfig - class Schema(BaseModel): """Class to store the database schema information.""" + model_config = BaseConfig() name: str tables: Optional[List[Table]] = Field(None) - - Config = BaseConfig