diff --git a/.coverage b/.coverage index 923cd2b..7dffaa8 100644 Binary files a/.coverage and b/.coverage differ diff --git a/ormar/fields/base.py b/ormar/fields/base.py index a558583..a057920 100644 --- a/ormar/fields/base.py +++ b/ormar/fields/base.py @@ -7,7 +7,7 @@ from ormar import ModelDefinitionError # noqa I101 if TYPE_CHECKING: # pragma no cover from ormar.models import Model - from ormar.models import FakePydantic + from ormar.models import NewBaseModel class BaseField: @@ -64,6 +64,6 @@ class BaseField: @classmethod def expand_relationship( - cls, value: Any, child: Union["Model", "FakePydantic"] + cls, value: Any, child: Union["Model", "NewBaseModel"] ) -> Any: return value diff --git a/ormar/models/__init__.py b/ormar/models/__init__.py index b70c515..bc6e7d0 100644 --- a/ormar/models/__init__.py +++ b/ormar/models/__init__.py @@ -1,4 +1,4 @@ -from ormar.models.fakepydantic import FakePydantic +from ormar.models.newbasemodel import NewBaseModel from ormar.models.model import Model -__all__ = ["FakePydantic", "Model"] +__all__ = ["NewBaseModel", "Model"] diff --git a/ormar/models/model.py b/ormar/models/model.py index ff6ae1d..84c3404 100644 --- a/ormar/models/model.py +++ b/ormar/models/model.py @@ -3,10 +3,10 @@ from typing import Any, List import sqlalchemy import ormar.queryset # noqa I100 -from ormar.models import FakePydantic # noqa I100 +from ormar.models import NewBaseModel # noqa I100 -class Model(FakePydantic): +class Model(NewBaseModel): __abstract__ = False @classmethod diff --git a/ormar/models/fakepydantic.py b/ormar/models/newbasemodel.py similarity index 99% rename from ormar/models/fakepydantic.py rename to ormar/models/newbasemodel.py index 1701336..932e2c2 100644 --- a/ormar/models/fakepydantic.py +++ b/ormar/models/newbasemodel.py @@ -33,7 +33,7 @@ if TYPE_CHECKING: # pragma no cover MappingIntStrAny = Mapping[IntStr, Any] -class FakePydantic(pydantic.BaseModel, ModelTableProxy, metaclass=ModelMetaclass): +class NewBaseModel(pydantic.BaseModel, ModelTableProxy, metaclass=ModelMetaclass): __slots__ = ("_orm_id", "_orm_saved") if TYPE_CHECKING: # pragma no cover diff --git a/ormar/relations.py b/ormar/relations.py index 61b3405..d6b7616 100644 --- a/ormar/relations.py +++ b/ormar/relations.py @@ -11,7 +11,7 @@ from sqlalchemy import text from ormar.fields.foreign_key import ForeignKeyField # noqa I100 if TYPE_CHECKING: # pragma no cover - from ormar.models import FakePydantic, Model + from ormar.models import NewBaseModel, Model def get_table_alias() -> str: @@ -48,7 +48,7 @@ class RelationshipManager: self._relations[reverse_key] = {"type": "reverse"} self._aliases[f"{field.to.Meta.tablename}_{table_name}"] = get_table_alias() - def deregister(self, model: "FakePydantic") -> None: + def deregister(self, model: "NewBaseModel") -> None: for rel_type in self._relations.keys(): if model.get_name() in rel_type.lower(): if model._orm_id in self._relations[rel_type]: @@ -56,8 +56,8 @@ class RelationshipManager: def add_relation( self, - parent: "FakePydantic", - child: "FakePydantic", + parent: "NewBaseModel", + child: "NewBaseModel", child_model_name: str, virtual: bool = False, ) -> None: @@ -95,13 +95,13 @@ class RelationshipManager: relations_list.append(model) - def contains(self, relations_key: str, instance: "FakePydantic") -> bool: + def contains(self, relations_key: str, instance: "NewBaseModel") -> bool: if relations_key in self._relations: return instance._orm_id in self._relations[relations_key] return False def get( - self, relations_key: str, instance: "FakePydantic" + self, relations_key: str, instance: "NewBaseModel" ) -> Union["Model", List["Model"]]: if relations_key in self._relations: if instance._orm_id in self._relations[relations_key]: