Skip to content

Commit

Permalink
ref: fix type errors in sentry.incidents (#72811)
Browse files Browse the repository at this point in the history
fixes errors when BaseManager becomes typechecked

<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Jun 17, 2024
1 parent 79afa4b commit 070a2b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/sentry/incidents/endpoints/serializers/alert_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ def get_attrs(
order_by=F("date_added").desc(),
)
)
activations = alert_activations_ranked.filter(alert_rule__in=item_list, rank__lte=10)
activations_qs = alert_activations_ranked.filter(alert_rule__in=item_list, rank__lte=10)
activations_by_alert_rule_id = defaultdict(list)
for activation in activations:
for activation in activations_qs:
activations_by_alert_rule_id[activation.alert_rule_id].append(activation)

alert_rule_projects = set()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ def serialize(self, obj, attrs, user, **kwargs):
class DetailedAlertRuleTriggerSerializer(AlertRuleTriggerSerializer):
def get_attrs(self, item_list, user, **kwargs):
triggers = {item.id: item for item in item_list}
result: DefaultDict[str, dict[str, list[str]]] = defaultdict(dict)
result: dict[str, dict[str, list[str]]] = defaultdict(lambda: defaultdict(list))
for trigger_id, project_slug in AlertRuleTriggerExclusion.objects.filter(
alert_rule_trigger__in=item_list
).values_list("alert_rule_trigger_id", "query_subscription__project__slug"):
exclusions = result[triggers[trigger_id]].setdefault("excludedProjects", [])
exclusions.append(project_slug)
if project_slug is not None:
result[triggers[trigger_id]]["excludedProjects"].append(project_slug)
return result

def serialize(self, obj, attrs, user, **kwargs):
Expand Down

0 comments on commit 070a2b3

Please sign in to comment.