From 2f931cc6f0415813e4d34381d820c225412726b3 Mon Sep 17 00:00:00 2001 From: Jeef Date: Mon, 11 Dec 2023 12:27:44 -0700 Subject: [PATCH] Pydantic v2 Support? --- pyproject.toml | 2 +- src/intellifire4py/model.py | 10 ++++++++-- tests/test_model.py | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f580d4b..401a670 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "intellifire4py" -version = "3.3.0" +version = "3.3.1" description = "Intellifire4Py" authors = ["Jeff Stein "] license = "MIT" diff --git a/src/intellifire4py/model.py b/src/intellifire4py/model.py index 6c6590c..7ce01bf 100644 --- a/src/intellifire4py/model.py +++ b/src/intellifire4py/model.py @@ -1,9 +1,15 @@ """Model definitions.""" from __future__ import annotations -from pydantic import Field + +try: + from pydantic.v1 import Field + from pydantic.v1 import BaseModel +except ImportError: + from pydantic import Field # type: ignore + from pydantic import BaseModel # type: ignore + from .const import IntelliFireErrorCode, IntelliFireApiMode -from pydantic import BaseModel from httpx import Cookies diff --git a/tests/test_model.py b/tests/test_model.py index f72e76b..15f4210 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -1,6 +1,9 @@ """Test File.""" -from pydantic import ValidationError +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError # type: ignore from intellifire4py.model import IntelliFirePollData