add internal forwardref stub

This commit is contained in:
collerek
2021-01-12 15:28:35 +01:00
parent fdef91d0c2
commit 3cf846ee23
4 changed files with 28 additions and 3 deletions

View File

@ -3,12 +3,13 @@ from dataclasses import dataclass
from typing import Any, List, Optional, TYPE_CHECKING, Tuple, Type, Union
from pydantic import BaseModel, create_model
from pydantic.typing import ForwardRef, evaluate_forwardref
from pydantic.typing import evaluate_forwardref
from sqlalchemy import UniqueConstraint
import ormar # noqa I101
from ormar.exceptions import RelationshipInstanceError
from ormar.fields.base import BaseField
from ormar.protocols.forward_ref import ForwardRef
if TYPE_CHECKING: # pragma no cover
from ormar.models import Model, NewBaseModel

View File

@ -1,9 +1,10 @@
from typing import Any, List, Optional, TYPE_CHECKING, Tuple, Type, Union
from pydantic.typing import ForwardRef, evaluate_forwardref
from pydantic.typing import evaluate_forwardref
import ormar # noqa: I100
from ormar.fields import BaseField
from ormar.fields.foreign_key import ForeignKeyField
from ormar.protocols.forward_ref import ForwardRef
if TYPE_CHECKING: # pragma no cover
from ormar.models import Model

View File

@ -1,9 +1,10 @@
from typing import Dict, List, Optional, TYPE_CHECKING, Tuple, Type
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
from ormar.protocols.forward_ref import ForwardRef
if TYPE_CHECKING: # pragma no cover
from ormar import Model

View File

@ -0,0 +1,22 @@
import sys
from typing import Any, TYPE_CHECKING
if sys.version_info < (3, 7): # pragma: no cover
if TYPE_CHECKING:
class ForwardRef:
_gorg = None
def __init__(self, args: Any) -> None:
pass
def _eval_type(self, globalns: Any, localns: Any) -> Any:
pass
else:
from typing import _ForwardRef as ForwardRef
else:
from typing import ForwardRef
ForwardRef = ForwardRef