Skip to content

Commit

Permalink
chore(deps): bump to pydantic v2
Browse files Browse the repository at this point in the history
  • Loading branch information
portellaa committed Oct 23, 2023
1 parent 8f4f622 commit 7dbc55c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/ydata_profiling/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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":
Expand All @@ -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):
Expand Down

0 comments on commit 7dbc55c

Please sign in to comment.