From b9d0766ef049a7b763307995ee8bfc34c05ca012 Mon Sep 17 00:00:00 2001 From: Artem Sorokin Date: Tue, 19 Nov 2024 12:35:21 +0300 Subject: [PATCH] Support for pydantic v2 using v1 shims --- custom_components/yandex_smart_home/cloud.py | 2 +- custom_components/yandex_smart_home/cloud_stream.py | 2 +- custom_components/yandex_smart_home/notifier.py | 2 +- custom_components/yandex_smart_home/schema/base.py | 4 ++-- custom_components/yandex_smart_home/schema/callback.py | 2 +- custom_components/yandex_smart_home/schema/capability.py | 2 +- .../yandex_smart_home/schema/capability_color.py | 2 +- .../yandex_smart_home/schema/capability_range.py | 2 +- custom_components/yandex_smart_home/schema/property_event.py | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/custom_components/yandex_smart_home/cloud.py b/custom_components/yandex_smart_home/cloud.py index fb9068a7..4b4e60a2 100644 --- a/custom_components/yandex_smart_home/cloud.py +++ b/custom_components/yandex_smart_home/cloud.py @@ -13,7 +13,7 @@ from homeassistant.helpers.aiohttp_client import SERVER_SOFTWARE, async_create_clientsession, async_get_clientsession from homeassistant.helpers.event import async_call_later from homeassistant.util import dt -from pydantic import BaseModel +from pydantic.v1 import BaseModel from . import handlers from .const import CLOUD_BASE_URL, DOMAIN, ISSUE_ID_RECONNECTING_TOO_FAST diff --git a/custom_components/yandex_smart_home/cloud_stream.py b/custom_components/yandex_smart_home/cloud_stream.py index 74b1a996..666bcded 100644 --- a/custom_components/yandex_smart_home/cloud_stream.py +++ b/custom_components/yandex_smart_home/cloud_stream.py @@ -28,7 +28,7 @@ from homeassistant.helpers.event import async_call_later from homeassistant.helpers.http import KEY_HASS from multidict import MultiDictProxy -from pydantic import BaseModel +from pydantic.v1 import BaseModel import yarl from .const import CLOUD_STREAM_BASE_URL diff --git a/custom_components/yandex_smart_home/notifier.py b/custom_components/yandex_smart_home/notifier.py index a8dc360e..cb462105 100644 --- a/custom_components/yandex_smart_home/notifier.py +++ b/custom_components/yandex_smart_home/notifier.py @@ -25,7 +25,7 @@ async_track_template_result, ) from homeassistant.helpers.template import Template -from pydantic import ValidationError +from pydantic.v1 import ValidationError from . import DOMAIN from .capability import Capability diff --git a/custom_components/yandex_smart_home/schema/base.py b/custom_components/yandex_smart_home/schema/base.py index a7329954..e8985bc3 100644 --- a/custom_components/yandex_smart_home/schema/base.py +++ b/custom_components/yandex_smart_home/schema/base.py @@ -2,8 +2,8 @@ from typing import Any -from pydantic import BaseModel -from pydantic.generics import GenericModel +from pydantic.v1 import BaseModel +from pydantic.v1.generics import GenericModel class APIModel(BaseModel): diff --git a/custom_components/yandex_smart_home/schema/callback.py b/custom_components/yandex_smart_home/schema/callback.py index 05dcd400..55c10016 100644 --- a/custom_components/yandex_smart_home/schema/callback.py +++ b/custom_components/yandex_smart_home/schema/callback.py @@ -6,7 +6,7 @@ from enum import StrEnum import time -from pydantic import Field +from pydantic.v1 import Field from .base import APIModel from .device import DeviceState diff --git a/custom_components/yandex_smart_home/schema/capability.py b/custom_components/yandex_smart_home/schema/capability.py index 10584237..bbd71b6d 100644 --- a/custom_components/yandex_smart_home/schema/capability.py +++ b/custom_components/yandex_smart_home/schema/capability.py @@ -3,7 +3,7 @@ from enum import StrEnum from typing import Annotated, Any, Literal, TypeVar, Union -from pydantic import Field +from pydantic.v1 import Field from .base import APIModel from .capability_color import ( diff --git a/custom_components/yandex_smart_home/schema/capability_color.py b/custom_components/yandex_smart_home/schema/capability_color.py index 639b4e08..123adac7 100644 --- a/custom_components/yandex_smart_home/schema/capability_color.py +++ b/custom_components/yandex_smart_home/schema/capability_color.py @@ -6,7 +6,7 @@ from enum import StrEnum from typing import Annotated, Any, Literal, Self, Union -from pydantic import Field, root_validator +from pydantic.v1 import Field, root_validator from .base import APIModel diff --git a/custom_components/yandex_smart_home/schema/capability_range.py b/custom_components/yandex_smart_home/schema/capability_range.py index 48e381e3..fce68433 100644 --- a/custom_components/yandex_smart_home/schema/capability_range.py +++ b/custom_components/yandex_smart_home/schema/capability_range.py @@ -6,7 +6,7 @@ from enum import StrEnum from typing import Any -from pydantic import root_validator, validator +from pydantic.v1 import root_validator, validator from .base import APIModel diff --git a/custom_components/yandex_smart_home/schema/property_event.py b/custom_components/yandex_smart_home/schema/property_event.py index 2ffeb395..6e6199ac 100644 --- a/custom_components/yandex_smart_home/schema/property_event.py +++ b/custom_components/yandex_smart_home/schema/property_event.py @@ -6,7 +6,7 @@ from enum import StrEnum from typing import Any, Generic, Literal, TypeVar -from pydantic import validator +from pydantic.v1 import validator from .base import GenericAPIModel