From fdef91d0c222c6ea3bbd6acaff3818180eaf9f49 Mon Sep 17 00:00:00 2001 From: collerek Date: Tue, 12 Jan 2021 15:02:10 +0100 Subject: [PATCH] change imports to pydantic for ForwardRef to avoid crashes on 3.6 --- ormar/fields/foreign_key.py | 4 ++-- ormar/fields/many_to_many.py | 4 ++-- ormar/models/helpers/models.py | 5 +++-- tests/test_forward_refs.py | 3 +-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ormar/fields/foreign_key.py b/ormar/fields/foreign_key.py index e5d187d..e93a2bc 100644 --- a/ormar/fields/foreign_key.py +++ b/ormar/fields/foreign_key.py @@ -1,9 +1,9 @@ import uuid from dataclasses import dataclass -from typing import Any, ForwardRef, List, Optional, TYPE_CHECKING, Tuple, Type, Union +from typing import Any, List, Optional, TYPE_CHECKING, Tuple, Type, Union from pydantic import BaseModel, create_model -from pydantic.typing import evaluate_forwardref +from pydantic.typing import ForwardRef, evaluate_forwardref from sqlalchemy import UniqueConstraint import ormar # noqa I101 diff --git a/ormar/fields/many_to_many.py b/ormar/fields/many_to_many.py index f789284..ae77364 100644 --- a/ormar/fields/many_to_many.py +++ b/ormar/fields/many_to_many.py @@ -1,6 +1,6 @@ -from typing import Any, ForwardRef, List, Optional, TYPE_CHECKING, Tuple, Type, Union +from typing import Any, List, Optional, TYPE_CHECKING, Tuple, Type, Union -from pydantic.typing import evaluate_forwardref +from pydantic.typing import ForwardRef, evaluate_forwardref import ormar # noqa: I100 from ormar.fields import BaseField from ormar.fields.foreign_key import ForeignKeyField diff --git a/ormar/models/helpers/models.py b/ormar/models/helpers/models.py index d2e3ef3..f7aeeeb 100644 --- a/ormar/models/helpers/models.py +++ b/ormar/models/helpers/models.py @@ -1,6 +1,7 @@ -from typing import Dict, ForwardRef, List, Optional, TYPE_CHECKING, Tuple, Type +from typing import Dict, List, Optional, TYPE_CHECKING, Tuple, Type -import ormar +from pydantic.typing import ForwardRef +import ormar # noqa: I100 from ormar.fields.foreign_key import ForeignKeyField from ormar.models.helpers.pydantic import populate_pydantic_default_values diff --git a/tests/test_forward_refs.py b/tests/test_forward_refs.py index 42ddcea..be355cf 100644 --- a/tests/test_forward_refs.py +++ b/tests/test_forward_refs.py @@ -1,10 +1,9 @@ # type: ignore -from typing import ForwardRef, List - import databases import pytest import sqlalchemy import sqlalchemy as sa +from pydantic.typing import ForwardRef from sqlalchemy import create_engine import ormar