Skip to content

Commit

Permalink
ref: fix typing of sentry.models.groupsubscription (#72591)
Browse files Browse the repository at this point in the history
<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Jun 13, 2024
1 parent 8b65f04 commit cf9d4a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ module = [
"sentry.mediators.sentry_app_installations.installation_notifier",
"sentry.migrations.*",
"sentry.models.eventattachment",
"sentry.models.groupsubscription",
"sentry.nodestore.base",
"sentry.nodestore.bigtable.backend",
"sentry.nodestore.django.backend",
Expand Down
36 changes: 20 additions & 16 deletions src/sentry/models/groupsubscription.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from collections.abc import Iterable, Mapping, Sequence
from collections.abc import Iterable
from typing import TYPE_CHECKING, ClassVar

from django.conf import settings
Expand Down Expand Up @@ -201,9 +201,9 @@ def get_participants(self, group: Group) -> ParticipantMap:
if user.id not in providers_by_recipient:
continue

subscription_option = subscriptions_by_user_id.get(user.id, {})
subscription_option = subscriptions_by_user_id.get(user.id)
if not subscription_option and has_team_workflow:
subscription_option = subscriptions_by_team_id.get(user.id, {})
subscription_option = subscriptions_by_team_id.get(user.id)

for provider_str, val in providers_by_recipient[user.id].items():
value = NotificationSettingsOptionEnum(val)
Expand Down Expand Up @@ -237,7 +237,7 @@ def get_possible_team_actors(self, group: Group) -> list[Actor]:

def get_subscriptions_by_team_id(
self, group: Group, possible_team_actors: list[Actor]
) -> Mapping[int, int]:
) -> dict[int, GroupSubscription]:
active_and_disabled_team_subscriptions = self.filter(
group=group, team_id__in=[t.id for t in possible_team_actors]
)
Expand All @@ -247,24 +247,28 @@ def get_subscriptions_by_team_id(
}

@staticmethod
def get_participating_user_ids(group: Group) -> Sequence[int]:
def get_participating_user_ids(group: Group) -> list[int]:
"""Return the list of user ids participating in this issue."""

return list(
GroupSubscription.objects.filter(group=group, is_active=True, team=None).values_list(
"user_id", flat=True
)
)
return [
user_id
for user_id in GroupSubscription.objects.filter(
group=group, is_active=True, team=None
).values_list("user_id", flat=True)
if user_id is not None
]

@staticmethod
def get_participating_team_ids(group: Group) -> Sequence[int]:
def get_participating_team_ids(group: Group) -> list[int]:
"""Return the list of team ids participating in this issue."""

return list(
GroupSubscription.objects.filter(group=group, is_active=True, user_id=None).values_list(
"team_id", flat=True
)
)
return [
team_id
for team_id in GroupSubscription.objects.filter(
group=group, is_active=True, user_id=None
).values_list("team_id", flat=True)
if team_id is not None
]


@region_silo_model
Expand Down

0 comments on commit cf9d4a8

Please sign in to comment.