Allow using Pydantic v2 (#533)
Co-authored-by: Chayim <chayim@users.noreply.github.com>
This commit is contained in:
parent
323787151e
commit
3a0fa0c7be
10 changed files with 45 additions and 14 deletions
7
tests/_compat.py
Normal file
7
tests/_compat.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from aredis_om._compat import PYDANTIC_V2
|
||||
|
||||
|
||||
if PYDANTIC_V2:
|
||||
from pydantic.v1 import EmailStr, ValidationError
|
||||
else:
|
||||
from pydantic import EmailStr, ValidationError
|
|
@ -10,7 +10,6 @@ from unittest import mock
|
|||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from pydantic import ValidationError
|
||||
|
||||
from aredis_om import (
|
||||
Field,
|
||||
|
@ -24,6 +23,7 @@ from aredis_om import (
|
|||
# We need to run this check as sync code (during tests) even in async mode
|
||||
# because we call it in the top-level module scope.
|
||||
from redis_om import has_redisearch
|
||||
from tests._compat import ValidationError
|
||||
|
||||
from .conftest import py_test_mark_asyncio
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ from unittest import mock
|
|||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from pydantic import ValidationError
|
||||
|
||||
from aredis_om import (
|
||||
EmbeddedJsonModel,
|
||||
|
@ -25,6 +24,7 @@ from aredis_om import (
|
|||
# We need to run this check as sync code (during tests) even in async mode
|
||||
# because we call it in the top-level module scope.
|
||||
from redis_om import has_redis_json
|
||||
from tests._compat import ValidationError
|
||||
|
||||
from .conftest import py_test_mark_asyncio
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ from typing import Optional
|
|||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from pydantic import ValidationError
|
||||
|
||||
from aredis_om import HashModel, Migrator, NotFoundError, RedisModelError
|
||||
from tests._compat import ValidationError
|
||||
|
||||
from .conftest import py_test_mark_asyncio
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ from collections import namedtuple
|
|||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from pydantic import EmailStr, ValidationError
|
||||
|
||||
from aredis_om import Field, HashModel, Migrator
|
||||
from tests._compat import EmailStr, ValidationError
|
||||
|
||||
|
||||
today = datetime.date.today()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue