Add support for pydantic v2 using v1 shims (#504)

This commit is contained in:
Teemu R 2023-08-28 17:48:49 +02:00 committed by GitHub
parent 0cb6f21d36
commit 53021f07fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 456 additions and 341 deletions

View File

@ -1,5 +1,8 @@
"""Cloud module implementation."""
from pydantic import BaseModel
try:
from pydantic.v1 import BaseModel
except ImportError:
from pydantic import BaseModel
from .module import Module

View File

@ -3,7 +3,11 @@ import logging
from enum import Enum
from typing import Dict, List, Optional
from pydantic import BaseModel
try:
from pydantic.v1 import BaseModel
except ImportError:
from pydantic import BaseModel
from .module import Module, merge

View File

@ -4,7 +4,10 @@ import re
from enum import Enum
from typing import Any, Dict, List, NamedTuple, Optional, cast
from pydantic import BaseModel, Field, root_validator
try:
from pydantic.v1 import BaseModel, Field, root_validator
except ImportError:
from pydantic import BaseModel, Field, root_validator
from .modules import Antitheft, Cloud, Countdown, Emeter, Schedule, Time, Usage
from .smartdevice import DeviceType, SmartDevice, SmartDeviceException, requires_update

779
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@ kasa = "kasa.cli:cli"
python = "^3.8"
anyio = "*" # see https://github.com/python-trio/asyncclick/issues/18
asyncclick = ">=8"
pydantic = "^1"
pydantic = ">=1"
# speed ups
orjson = { "version" = ">=3.9.1", optional = true }