From 7dbc55cc535bbd9aa94c52dc046223b94bb9be4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Portela=20Afonso?= Date: Mon, 23 Oct 2023 16:09:30 +0100 Subject: [PATCH] chore(deps): bump to pydantic v2 --- requirements.txt | 3 ++- src/ydata_profiling/config.py | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index dd9f1a869..f609cdbca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ scipy>=1.4.1, <1.12 pandas>1.1, <2.1, !=1.4.0 matplotlib>=3.2, <=3.7.3 -pydantic>=1.8.1, <2 +pydantic>=2 +pydantic-settings>=2 PyYAML>=5.0.0, <6.1 jinja2>=2.11.1, <3.2 visions[type_image_path]==0.7.5 diff --git a/src/ydata_profiling/config.py b/src/ydata_profiling/config.py index f4b8caedb..7a032656f 100644 --- a/src/ydata_profiling/config.py +++ b/src/ydata_profiling/config.py @@ -4,7 +4,8 @@ from typing import Any, Dict, List, Optional, Tuple, Union import yaml -from pydantic import BaseModel, BaseSettings, Field, PrivateAttr +from pydantic import BaseModel, Field, PrivateAttr +from pydantic_settings import BaseSettings, SettingsConfigDict def _merge_dictionaries(dict1: dict, dict2: dict) -> dict: @@ -287,8 +288,7 @@ class Report(BaseModel): class Settings(BaseSettings): # Default prefix to avoid collisions with environment variables - class Config: - env_prefix = "profile_" + model_config = SettingsConfigDict(env_prefix="profile_") # Title of the document title: str = "Pandas Profiling Report" @@ -348,11 +348,11 @@ class Config: # Report rendering report: Report = Report() html: Html = Html() - notebook = Notebook() + notebook: Notebook = Notebook() def update(self, updates: dict) -> "Settings": update = _merge_dictionaries(self.dict(), updates) - return self.parse_obj(self.copy(update=update)) + return self.model_validate(self.model_copy(update=update)) @staticmethod def from_file(config_file: Union[Path, str]) -> "Settings": @@ -366,7 +366,7 @@ def from_file(config_file: Union[Path, str]) -> "Settings": with open(config_file) as f: data = yaml.safe_load(f) - return Settings().parse_obj(data) + return Settings().model_validate(data) class SparkSettings(Settings):