diff --git a/pyproject.toml b/pyproject.toml index 00fee83a679699..1154df28067415 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/src/sentry/models/groupsubscription.py b/src/sentry/models/groupsubscription.py index 1de9d6e841c70f..5b8743b8424faa 100644 --- a/src/sentry/models/groupsubscription.py +++ b/src/sentry/models/groupsubscription.py @@ -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 @@ -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) @@ -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] ) @@ -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