Allow using Pydantic v2 (#533)

Co-authored-by: Chayim <chayim@users.noreply.github.com>
This commit is contained in:
Manabu Niseki 2023-07-12 17:48:08 +09:00 committed by GitHub
parent 323787151e
commit 3a0fa0c7be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 45 additions and 14 deletions

7
tests/_compat.py Normal file
View 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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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()