Skip to content

Commit b01eed8

Browse files
committed
use annotations to avoinf circular imports
1 parent b180250 commit b01eed8

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

api/types/type_organization.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from typing import TYPE_CHECKING, Any, List, Optional
1+
from __future__ import annotations
2+
3+
from typing import Any, List, Optional
24

35
import strawberry
46
import strawberry_django
@@ -8,9 +10,6 @@
810
from api.models import Organization
911
from api.types.base_type import BaseType
1012

11-
if TYPE_CHECKING:
12-
from authorization.types import TypeOrganizationMembership
13-
1413

1514
@strawberry_django.filter(Organization)
1615
class OrganizationFilter:
@@ -138,3 +137,7 @@ def members(self, info: Info) -> List["TypeOrganizationMembership"]:
138137
return TypeOrganizationMembership.from_django_list(queryset)
139138
except Exception:
140139
return []
140+
141+
142+
# Import at the end to avoid circular imports but make it available for string resolution
143+
from authorization.types import TypeOrganizationMembership # noqa: E402

api/types/type_user.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from typing import TYPE_CHECKING, List, Optional
1+
from __future__ import annotations
2+
3+
from typing import List, Optional
24

35
import strawberry
46
import strawberry_django
@@ -7,9 +9,6 @@
79
from api.types.base_type import BaseType
810
from authorization.models import OrganizationMembership, Role, User
911

10-
if TYPE_CHECKING:
11-
from authorization.types import TypeOrganizationMembership
12-
1312

1413
@strawberry_django.filter(User)
1514
class UserFilter:
@@ -75,3 +74,7 @@ def full_name(self) -> str:
7574
return last_name
7675
else:
7776
return getattr(self, "username", "")
77+
78+
79+
# Import at the end to avoid circular imports but make it available for string resolution
80+
from authorization.types import TypeOrganizationMembership # noqa: E402

0 commit comments

Comments
 (0)