Skip to content

Commit af27540

Browse files
ref: fix a few annotations in models.organization (#90970)
<!-- Describe your PR here. -->
1 parent 3642446 commit af27540

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/sentry/api/endpoints/organization_index.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from django.conf import settings
44
from django.db import IntegrityError
55
from django.db.models import Count, Q
6-
from django.db.models.query import QuerySet
76
from drf_spectacular.utils import extend_schema
87
from rest_framework import serializers, status
98
from rest_framework.request import Request
@@ -98,7 +97,7 @@ def get(self, request: Request) -> Response:
9897
"""
9998
owner_only = request.GET.get("owner") in ("1", "true")
10099

101-
queryset: QuerySet[Organization] = Organization.objects.distinct()
100+
queryset = Organization.objects.distinct()
102101

103102
if request.auth and not request.user.is_authenticated:
104103
if hasattr(request.auth, "project"):

src/sentry/models/organization.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from django.conf import settings
88
from django.db import models, router, transaction
9-
from django.db.models import QuerySet
109
from django.urls import NoReverseMatch, reverse
1110
from django.utils import timezone
1211
from django.utils.functional import cached_property
@@ -25,6 +24,7 @@
2524
from sentry.db.models import BoundedPositiveIntegerField, region_silo_model, sane_repr
2625
from sentry.db.models.fields.slug import SentryOrgSlugField
2726
from sentry.db.models.manager.base import BaseManager
27+
from sentry.db.models.manager.base_query_set import BaseQuerySet
2828
from sentry.db.models.utils import slugify_instance
2929
from sentry.db.postgres.transactions import in_test_hide_transaction_boundary
3030
from sentry.hybridcloud.outbox.base import ReplicatedRegionModel
@@ -86,14 +86,14 @@ def as_choices(cls):
8686

8787

8888
class OrganizationManager(BaseManager["Organization"]):
89-
def get_for_user_ids(self, user_ids: Collection[int]) -> QuerySet:
89+
def get_for_user_ids(self, user_ids: Collection[int]) -> BaseQuerySet[Organization]:
9090
"""Returns the QuerySet of all organizations that a set of Users have access to."""
9191
return self.filter(
9292
status=OrganizationStatus.ACTIVE,
9393
member_set__user_id__in=user_ids,
9494
)
9595

96-
def get_for_team_ids(self, team_ids: Sequence[int]) -> QuerySet:
96+
def get_for_team_ids(self, team_ids: Sequence[int]) -> BaseQuerySet[Organization]:
9797
"""Returns the QuerySet of all organizations that a set of Teams have access to."""
9898
from sentry.models.team import Team
9999

@@ -102,7 +102,7 @@ def get_for_team_ids(self, team_ids: Sequence[int]) -> QuerySet:
102102
id__in=Team.objects.filter(id__in=team_ids).values("organization"),
103103
)
104104

105-
def get_for_user(self, user, scope=None, only_visible=True):
105+
def get_for_user(self, user, scope=None, only_visible=True) -> list[Organization]:
106106
"""
107107
Returns a set of all organizations a user has access to.
108108
"""
@@ -121,7 +121,7 @@ def get_for_user(self, user, scope=None, only_visible=True):
121121
return [r.organization for r in results if scope in r.get_scopes()]
122122
return [r.organization for r in results]
123123

124-
def get_organizations_where_user_is_owner(self, user_id: int) -> QuerySet:
124+
def get_organizations_where_user_is_owner(self, user_id: int) -> BaseQuerySet[Organization]:
125125
"""
126126
Returns a QuerySet of all organizations where a user has the top priority role.
127127
The default top priority role in Sentry is owner.

0 commit comments

Comments
 (0)