From 28de03360f1a02b3dc1d9ef37d5057e116ca7c46 Mon Sep 17 00:00:00 2001 From: Jonny Saunders Date: Wed, 3 Apr 2024 01:07:06 -0700 Subject: [PATCH] Use model_config when pydantic v2 (#108) --- src/curies/api.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/curies/api.py b/src/curies/api.py index 7e8e024..053f6e1 100644 --- a/src/curies/api.py +++ b/src/curies/api.py @@ -36,7 +36,10 @@ from pydantic import BaseModel, Field from pytrie import StringTrie -from ._pydantic_compat import field_validator, get_field_validator_values +from ._pydantic_compat import PYDANTIC_V1, field_validator, get_field_validator_values + +if not PYDANTIC_V1: + from pydantic import ConfigDict if TYPE_CHECKING: # pragma: no cover import pandas @@ -201,10 +204,15 @@ class notion of parsed reference (instead of merely stringified ..., description="The local unique identifier used in a compact URI (CURIE)." ) - class Config: - """Pydantic configuration for references.""" + if PYDANTIC_V1: + + class Config: + """Pydantic configuration for references.""" - frozen = True + frozen = True + + else: + model_config = ConfigDict(frozen=True) @property def curie(self) -> str: