diff --git a/.coverage b/.coverage index 86117f6..d262878 100644 Binary files a/.coverage and b/.coverage differ diff --git a/ormar/__init__.py b/ormar/__init__.py index bfa2e87..90db22e 100644 --- a/ormar/__init__.py +++ b/ormar/__init__.py @@ -39,4 +39,5 @@ __all__ = [ "NoMatch", "ForeignKey", "QuerySet", + "RelationType", ] diff --git a/ormar/relations/__init__.py b/ormar/relations/__init__.py index 54860f5..52ed667 100644 --- a/ormar/relations/__init__.py +++ b/ormar/relations/__init__.py @@ -1,5 +1,5 @@ -from ormar.relations.relation import Relation, RelationType from ormar.relations.alias_manager import AliasManager +from ormar.relations.relation import Relation, RelationType from ormar.relations.relation_manager import RelationsManager __all__ = ["AliasManager", "Relation", "RelationsManager", "RelationType"] diff --git a/ormar/relations/querysetproxy.py b/ormar/relations/querysetproxy.py index 23516e2..01066f0 100644 --- a/ormar/relations/querysetproxy.py +++ b/ormar/relations/querysetproxy.py @@ -1,10 +1,11 @@ -from typing import TYPE_CHECKING, Union, List, Any, Tuple +from typing import Any, List, TYPE_CHECKING, Tuple, Union import ormar if TYPE_CHECKING: # pragma no cover from ormar.relations import Relation from ormar.models import Model + from ormar.queryset import QuerySet class QuerysetProxy: diff --git a/ormar/relations/relation.py b/ormar/relations/relation.py index 5ec709c..01e0ec4 100644 --- a/ormar/relations/relation.py +++ b/ormar/relations/relation.py @@ -77,5 +77,3 @@ class Relation: def __repr__(self) -> str: # pragma no cover return str(self.related_models) - - diff --git a/ormar/relations/relation_manager.py b/ormar/relations/relation_manager.py index 8dc1e21..1407182 100644 --- a/ormar/relations/relation_manager.py +++ b/ormar/relations/relation_manager.py @@ -1,5 +1,5 @@ -from _weakref import proxy -from typing import List, Type, Optional, Union, Tuple +from typing import List, Optional, TYPE_CHECKING, Tuple, Type, Union +from weakref import proxy import ormar from ormar.exceptions import RelationshipInstanceError @@ -8,6 +8,9 @@ from ormar.fields.many_to_many import ManyToManyField from ormar.relations import Relation from ormar.relations.relation import RelationType +if TYPE_CHECKING: # pragma no cover + from ormar import Model + class RelationsManager: def __init__( @@ -125,4 +128,4 @@ class RelationsManager: if name in item._orm: relation_name = item.resolve_relation_name(related_model, item) item._orm.remove(name, related_model) - related_model._orm.remove(relation_name, item) \ No newline at end of file + related_model._orm.remove(relation_name, item) diff --git a/ormar/relations/relation_proxy.py b/ormar/relations/relation_proxy.py index a3bdebd..8b0ff34 100644 --- a/ormar/relations/relation_proxy.py +++ b/ormar/relations/relation_proxy.py @@ -40,8 +40,8 @@ class RelationProxy(list): kwargs = {f"{owner_table}__{pkname}": pk_value} queryset = ( ormar.QuerySet(model_cls=self.relation.to) - .select_related(owner_table) - .filter(**kwargs) + .select_related(owner_table) + .filter(**kwargs) ) return queryset