Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: fix typing of sentry.models.groupsubscription #72591

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,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
Loading