From e2f6c1aaa99aebd1721fe263ca9a37218dbe9f32 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Mon, 13 Nov 2023 18:34:07 +0100 Subject: [PATCH] Fix compatibility issue with pydantic 2.5.0 Import FieldInfo from its original package --- news/18.bugfix | 4 ++++ src/extendable_pydantic/main.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 news/18.bugfix diff --git a/news/18.bugfix b/news/18.bugfix new file mode 100644 index 0000000..80e754e --- /dev/null +++ b/news/18.bugfix @@ -0,0 +1,4 @@ +From Pydantic 2.5.0 the FieldInfo class is no more available in the pydantic.main +module. Its only available in the pydantic.fields module. The import from the +pydantic.main module was a mistake since it relied on an transitive import from +pydantic.fields to pydantic.main. This is no more the case in Pydantic 2.5.0. diff --git a/src/extendable_pydantic/main.py b/src/extendable_pydantic/main.py index 0fb2cec..7a03109 100644 --- a/src/extendable_pydantic/main.py +++ b/src/extendable_pydantic/main.py @@ -15,7 +15,8 @@ from typing import _Final as _TypingBase # type: ignore[attr-defined,unused-ignore] from pydantic._internal._model_construction import ModelMetaclass -from pydantic.main import BaseModel, FieldInfo +from pydantic.fields import FieldInfo +from pydantic.main import BaseModel from .utils import all_identical, resolve_annotation