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,4 +1,7 @@
"""Cloud module implementation."""
try:
from pydantic.v1 import BaseModel
except ImportError:
from pydantic import BaseModel
from .module import Module

View File

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

View File

@ -4,6 +4,9 @@ import re
from enum import Enum
from typing import Any, Dict, List, NamedTuple, Optional, cast
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

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 }