diff --git a/mira/dkg/client.py b/mira/dkg/client.py index 9f123010..e2387356 100644 --- a/mira/dkg/client.py +++ b/mira/dkg/client.py @@ -14,7 +14,7 @@ import pystow import requests from neo4j import GraphDatabase, Transaction, unit_of_work -from pydantic import BaseModel, Field, validator +from pydantic import BaseModel, Field, field_validator from tqdm import tqdm from typing_extensions import Literal, TypeAlias @@ -110,9 +110,7 @@ class Entity(BaseModel): # Gets auto-populated link: Optional[str] = None - # TODO[pydantic]: We couldn't refactor the `validator`, please replace it by `field_validator` manually. - # Check https://docs.pydantic.dev/dev-v2/migration/#changes-to-validators for more information. - @validator("link") + @field_validator("link") def set_link(cls, value, values): """ Set the value of the ``link`` field based on the value of the ``id`` diff --git a/mira/metamodel/utils.py b/mira/metamodel/utils.py index da6d924a..da42c808 100644 --- a/mira/metamodel/utils.py +++ b/mira/metamodel/utils.py @@ -39,9 +39,7 @@ def safe_parse_expr(s: str, local_dict=None) -> sympy.Expr: class SympyExprStr(sympy.Expr): @classmethod - # TODO[pydantic]: We couldn't refactor `__get_validators__`, please create the `__get_pydantic_core_schema__` manually. - # Check https://docs.pydantic.dev/latest/migration/#defining-custom-types for more information. - def __get_validators__(cls): + def __get_pydantic_core_schema__(cls): yield cls.validate @classmethod