From 2507eba9d9f0774ab144a77688d660dc7fb3589d Mon Sep 17 00:00:00 2001 From: Simon Brugman Date: Thu, 6 Jul 2023 15:24:12 +0200 Subject: [PATCH] upgrade to pydantic 2 Closes #274 --- popmon/config.py | 5 +++-- pyproject.toml | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/popmon/config.py b/popmon/config.py index a85feba1..51169cee 100644 --- a/popmon/config.py +++ b/popmon/config.py @@ -21,7 +21,8 @@ import pandas as pd from histogrammar.dfinterface.make_histograms import get_time_axes -from pydantic import BaseModel, BaseSettings +from pydantic import BaseModel +from pydantic_settings import BaseSettings from typing_extensions import Literal # Global configuration for the joblib parallelization. Could be used to change the number of jobs, and/or change @@ -32,7 +33,7 @@ class ValidatedSettings(BaseSettings): class Config: - validate_all = True + validate_default = True validate_assignment = True diff --git a/pyproject.toml b/pyproject.toml index 05594d03..c9195079 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,8 @@ dependencies = [ "plotly>=5.8.0", "joblib>=0.14.0", "htmlmin", - "pydantic", + "pydantic>=2", + "pydantic-settings", "typing_extensions", "tomli >= 1.1.0 ; python_version < '3.11'" ] @@ -106,6 +107,10 @@ ignore = [ "TRY003", "E501", "DTZ", + "PERF203", # `try`-`except` within a loop incurs performance overhead + + # False positive + "PERF401", # Use a list comprehension to create a transformed list # Prefer autofix "PD011", # .to_numpy() instead of values @@ -154,6 +159,10 @@ ignore = [ "INP001", ] +"popmon/config.py" = [ + "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` +] + # Notebooks & NBQA "popmon/notebooks/*" = [ # Imports cannot be checked properly with NBQA