Skip to content

Commit

Permalink
fix: pydantic and typeguard (#153)
Browse files Browse the repository at this point in the history
* fix: pydantic and typeguard

* fix(linting): code formatting

---------

Co-authored-by: Azory YData Bot <[email protected]>
  • Loading branch information
portellaa and azory-ydata authored Feb 3, 2025
1 parent 6b56714 commit c6c7277
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]

Expand Down
10 changes: 5 additions & 5 deletions src/ydata/sdk/common/model.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -13,4 +13,4 @@ class BaseModel(PydanticBaseModel):
All datamodel from YData SDK inherits from this class.
"""
Config = Config
model_config = Config()
13 changes: 5 additions & 8 deletions src/ydata/sdk/connectors/_models/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit c6c7277

Please sign in to comment.