python311Packages.aionotion: apply patch for pydantic>=2
This commit is contained in:
@@ -39,6 +39,9 @@ buildPythonPackage rec {
|
||||
url = "https://github.com/bachya/aionotion/commit/53c7285110d12810f9b43284295f71d052a81b83.patch";
|
||||
hash = "sha256-RLRbHmaR2A8MNc96WHx0L8ccyygoBUaOulAuRJkFuUM=";
|
||||
})
|
||||
|
||||
# based on https://github.com/bachya/aionotion/pull/235
|
||||
./pydantic_2-compatibility.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
diff --git a/aionotion/bridge/models.py b/aionotion/bridge/models.py
|
||||
index 260566d..f2e640c 100644
|
||||
--- a/aionotion/bridge/models.py
|
||||
+++ b/aionotion/bridge/models.py
|
||||
@@ -5,7 +5,10 @@ from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from typing import Optional, Union
|
||||
|
||||
-from pydantic import BaseModel, validator
|
||||
+try:
|
||||
+ from pydantic.v1 import BaseModel, validator
|
||||
+except ModuleNotFoundError:
|
||||
+ from pydantic import BaseModel, validator
|
||||
|
||||
from aionotion.helpers.validators import validate_timestamp
|
||||
|
||||
diff --git a/aionotion/client.py b/aionotion/client.py
|
||||
index 5332334..e2f9035 100644
|
||||
--- a/aionotion/client.py
|
||||
+++ b/aionotion/client.py
|
||||
@@ -5,7 +5,10 @@ from typing import Any, cast
|
||||
|
||||
from aiohttp import ClientSession, ClientTimeout
|
||||
from aiohttp.client_exceptions import ClientError
|
||||
-from pydantic import BaseModel, ValidationError
|
||||
+try:
|
||||
+ from pydantic.v1 import BaseModel, ValidationError
|
||||
+except ModuleNotFoundError:
|
||||
+ from pydantic import BaseModel, ValidationError
|
||||
|
||||
from aionotion.bridge import Bridge
|
||||
from aionotion.const import LOGGER
|
||||
diff --git a/aionotion/device/models.py b/aionotion/device/models.py
|
||||
index c19bc3e..ea7f577 100644
|
||||
--- a/aionotion/device/models.py
|
||||
+++ b/aionotion/device/models.py
|
||||
@@ -4,7 +4,10 @@ from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
-from pydantic import BaseModel, validator
|
||||
+try:
|
||||
+ from pydantic.v1 import BaseModel, validator
|
||||
+except ModuleNotFoundError:
|
||||
+ from pydantic import BaseModel, validator
|
||||
|
||||
from aionotion.helpers.validators import validate_timestamp
|
||||
|
||||
diff --git a/aionotion/helpers/typing.py b/aionotion/helpers/typing.py
|
||||
index 130c5ab..b2c3726 100644
|
||||
--- a/aionotion/helpers/typing.py
|
||||
+++ b/aionotion/helpers/typing.py
|
||||
@@ -1,6 +1,9 @@
|
||||
"""Define typing helpers."""
|
||||
from typing import TypeVar
|
||||
|
||||
-from pydantic import BaseModel
|
||||
+try:
|
||||
+ from pydantic.v1 import BaseModel
|
||||
+except ModuleNotFoundError:
|
||||
+ from pydantic import BaseModel
|
||||
|
||||
BaseModelT = TypeVar("BaseModelT", bound=BaseModel)
|
||||
diff --git a/aionotion/sensor/models.py b/aionotion/sensor/models.py
|
||||
index 3bcfb12..643a282 100644
|
||||
--- a/aionotion/sensor/models.py
|
||||
+++ b/aionotion/sensor/models.py
|
||||
@@ -6,7 +6,10 @@ from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Any, Literal, Optional
|
||||
|
||||
-from pydantic import BaseModel, Extra, validator
|
||||
+try:
|
||||
+ from pydantic.v1 import BaseModel, Extra, validator
|
||||
+except ModuleNotFoundError:
|
||||
+ from pydantic import BaseModel, Extra, validator
|
||||
|
||||
from aionotion.const import LOGGER
|
||||
from aionotion.helpers.validators import validate_timestamp
|
||||
diff --git a/aionotion/system/models.py b/aionotion/system/models.py
|
||||
index d5b27d3..7931959 100644
|
||||
--- a/aionotion/system/models.py
|
||||
+++ b/aionotion/system/models.py
|
||||
@@ -5,7 +5,10 @@ from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
-from pydantic import BaseModel, validator
|
||||
+try:
|
||||
+ from pydantic.v1 import BaseModel, validator
|
||||
+except ModuleNotFoundError:
|
||||
+ from pydantic import BaseModel, validator
|
||||
|
||||
from aionotion.helpers.validators import validate_timestamp
|
||||
|
||||
diff --git a/aionotion/user/models.py b/aionotion/user/models.py
|
||||
index 856fbc3..723041e 100644
|
||||
--- a/aionotion/user/models.py
|
||||
+++ b/aionotion/user/models.py
|
||||
@@ -2,7 +2,10 @@
|
||||
# pylint: disable=too-few-public-methods
|
||||
from __future__ import annotations
|
||||
|
||||
-from pydantic import BaseModel
|
||||
+try:
|
||||
+ from pydantic.v1 import BaseModel
|
||||
+except ModuleNotFoundError:
|
||||
+ from pydantic import BaseModel
|
||||
|
||||
|
||||
class UserPreferences(BaseModel):
|
||||
Reference in New Issue
Block a user