Skip to content

Commit

Permalink
fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
MeredithAnya committed Nov 8, 2024
1 parent 6be6349 commit e26301f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions snuba/lw_deletions/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ def format(
project_id [1] and group_id [1, 2, 3, 4]
"""
mapping: MutableMapping[int, list[int]] = defaultdict(set)
mapping: MutableMapping[int, set[int]] = defaultdict(set)
conditions = [message["conditions"] for message in messages]
for condition in conditions:
project_id = condition["project_id"][0]
mapping[project_id] = mapping[project_id].union(set(condition["group_id"]))
# appease mypy
assert isinstance(project_id, int)
mapping[project_id] = mapping[project_id].union(
# using int() to make mypy happy
set([int(g_id) for g_id in condition["group_id"]])
)

return [
{"project_id": [project_id], "group_id": list(group_ids)}
Expand Down
4 changes: 2 additions & 2 deletions tests/lw_deletions/test_formatters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Sequence
from typing import Sequence, Type

import pytest

Expand Down Expand Up @@ -61,7 +61,7 @@ def create_delete_query_message(conditions: ConditionsType) -> DeleteQueryMessag
def test_search_issues_formatter(
messages: Sequence[DeleteQueryMessage],
expected_formatted: Sequence[ConditionsType],
formatter: Formatter,
formatter: Type[Formatter],
) -> None:
formatted = formatter().format(messages)
assert formatted == expected_formatted

0 comments on commit e26301f

Please sign in to comment.