From 9f1f77ea17ea15046b5cf87284f96d9e11733f03 Mon Sep 17 00:00:00 2001 From: anthony sottile Date: Mon, 21 Apr 2025 14:56:35 -0400 Subject: [PATCH 1/2] ref: run auto-type-annotate on **/issues/**.py --- src/sentry/issues/endpoints/group_hashes.py | 11 +++++-- .../endpoints/organization_issues_count.py | 4 ++- ...ation_group_search_view_details_starred.py | 30 ++++++++++--------- ...ization_group_search_view_starred_order.py | 22 +++++++------- ...organization_group_search_views_starred.py | 6 ++-- .../test_organization_group_suspect_flags.py | 19 ++++++++---- .../test_organization_group_suspect_tags.py | 10 +++---- .../test_organization_issue_metrics.py | 18 +++++------ tests/sentry/issues/test_suspect_flags.py | 15 +++++++--- tests/sentry/issues/test_suspect_tags.py | 6 ++-- 10 files changed, 83 insertions(+), 58 deletions(-) diff --git a/src/sentry/issues/endpoints/group_hashes.py b/src/sentry/issues/endpoints/group_hashes.py index 69a095e4824e90..4f48fbf5b616a7 100644 --- a/src/sentry/issues/endpoints/group_hashes.py +++ b/src/sentry/issues/endpoints/group_hashes.py @@ -1,5 +1,6 @@ from functools import partial +from django.contrib.auth.models import AnonymousUser from rest_framework.request import Request from rest_framework.response import Response @@ -12,6 +13,8 @@ from sentry.models.group import Group from sentry.models.grouphash import GroupHash from sentry.tasks.unmerge import unmerge +from sentry.users.models.user import User +from sentry.users.services.user.model import RpcUser from sentry.utils import metrics from sentry.utils.snuba import raw_query @@ -95,12 +98,16 @@ def put(self, request: Request, group: Group) -> Response: return Response(status=202) - def __handle_results(self, project_id, group_id, user, full, results): + def __handle_results( + self, project_id, group_id, user: User | RpcUser | AnonymousUser | None, full, results + ): return [ self.__handle_result(user, project_id, group_id, full, result) for result in results ] - def __handle_result(self, user, project_id, group_id, full, result): + def __handle_result( + self, user: User | RpcUser | AnonymousUser | None, project_id, group_id, full, result + ): event = eventstore.backend.get_event_by_id(project_id, result["event_id"]) serializer = EventSerializer if full else SimpleEventSerializer diff --git a/src/sentry/issues/endpoints/organization_issues_count.py b/src/sentry/issues/endpoints/organization_issues_count.py index 7aa5a481008903..8bd60902176c17 100644 --- a/src/sentry/issues/endpoints/organization_issues_count.py +++ b/src/sentry/issues/endpoints/organization_issues_count.py @@ -13,6 +13,8 @@ from sentry.api.issue_search import convert_query_values, parse_search_query from sentry.api.utils import get_date_range_from_params from sentry.exceptions import InvalidParams +from sentry.models.organization import Organization +from sentry.organizations.services.organization.model import RpcOrganization from sentry.snuba import discover from sentry.types.ratelimit import RateLimit, RateLimitCategory @@ -65,7 +67,7 @@ def _count( result = search.backend.query(**query_kwargs) return result.hits - def get(self, request: Request, organization) -> Response: + def get(self, request: Request, organization: Organization | RpcOrganization) -> Response: stats_period = request.GET.get("groupStatsPeriod") try: start, end = get_date_range_from_params(request.GET) diff --git a/tests/sentry/issues/endpoints/test_organization_group_search_view_details_starred.py b/tests/sentry/issues/endpoints/test_organization_group_search_view_details_starred.py index 41488148518f0e..898df90b36e67b 100644 --- a/tests/sentry/issues/endpoints/test_organization_group_search_view_details_starred.py +++ b/tests/sentry/issues/endpoints/test_organization_group_search_view_details_starred.py @@ -10,12 +10,12 @@ class OrganizationGroupSearchViewDetailsStarredEndpointTest(APITestCase): endpoint = "sentry-api-0-organization-group-search-view-starred" method = "post" - def setUp(self): + def setUp(self) -> None: super().setUp() self.login_as(user=self.user) self.org = self.create_organization(owner=self.user) - def get_url(self, view_id): + def get_url(self, view_id: int) -> str: return reverse( self.endpoint, kwargs={ @@ -24,7 +24,9 @@ def get_url(self, view_id): }, ) - def create_view(self, user_id=None, visibility=None, starred=False): + def create_view( + self, user_id: int | None = None, visibility: str | None = None, starred: bool = False + ) -> GroupSearchView: user_id = user_id or self.user.id visibility = visibility or GroupSearchViewVisibility.OWNER @@ -45,13 +47,13 @@ def create_view(self, user_id=None, visibility=None, starred=False): return view @with_feature("organizations:issue-stream-custom-views") - def test_view_not_found(self): + def test_view_not_found(self) -> None: response = self.client.post(self.get_url(737373), data={"starred": True}) assert response.status_code == 404 @with_feature("organizations:issue-stream-custom-views") - def test_organization_view_accessible(self): + def test_organization_view_accessible(self) -> None: other_user = self.create_user() view = self.create_view( user_id=other_user.id, visibility=GroupSearchViewVisibility.ORGANIZATION @@ -67,7 +69,7 @@ def test_organization_view_accessible(self): ).exists() @with_feature("organizations:issue-stream-custom-views") - def test_invalid_request_data(self): + def test_invalid_request_data(self) -> None: view = self.create_view() # Missing starred field @@ -79,7 +81,7 @@ def test_invalid_request_data(self): assert response.status_code == 400 @with_feature("organizations:issue-stream-custom-views") - def test_star_view_with_position(self): + def test_star_view_with_position(self) -> None: view1 = self.create_view(starred=True) view2 = self.create_view(starred=True) view_to_be_starred = self.create_view() @@ -111,7 +113,7 @@ def test_star_view_with_position(self): ).exists() @with_feature("organizations:issue-stream-custom-views") - def test_star_view_without_position(self): + def test_star_view_without_position(self) -> None: view = self.create_view() response = self.client.post(self.get_url(view.id), data={"starred": True}) @@ -127,7 +129,7 @@ def test_star_view_without_position(self): assert starred_view.position == 0 @with_feature("organizations:issue-stream-custom-views") - def test_unstar_view(self): + def test_unstar_view(self) -> None: starred_view = self.create_view(starred=True) view_to_be_unstarred = self.create_view(starred=True) @@ -146,7 +148,7 @@ def test_unstar_view(self): ).exists() @with_feature("organizations:issue-stream-custom-views") - def test_star_already_starred_view(self): + def test_star_already_starred_view(self) -> None: view = self.create_view(starred=True) response = self.client.post(self.get_url(view.id), data={"starred": True}) @@ -154,7 +156,7 @@ def test_star_already_starred_view(self): assert response.status_code == 204 @with_feature("organizations:issue-stream-custom-views") - def test_unstar_not_starred_view(self): + def test_unstar_not_starred_view(self) -> None: view = self.create_view() response = self.client.post(self.get_url(view.id), data={"starred": False}) @@ -162,7 +164,7 @@ def test_unstar_not_starred_view(self): assert response.status_code == 204 @with_feature("organizations:issue-stream-custom-views") - def test_multiple_starred_views_order(self): + def test_multiple_starred_views_order(self) -> None: view1 = self.create_view() view2 = self.create_view() view3 = self.create_view() @@ -205,7 +207,7 @@ def test_multiple_starred_views_order(self): ) @with_feature("organizations:issue-stream-custom-views") - def test_unstar_adjust_positions(self): + def test_unstar_adjust_positions(self) -> None: view1 = self.create_view(starred=True) view2 = self.create_view(starred=True) view3 = self.create_view(starred=True) @@ -233,7 +235,7 @@ def test_unstar_adjust_positions(self): == 0 ) - def test_error_when_feature_flag_disabled(self): + def test_error_when_feature_flag_disabled(self) -> None: view = self.create_view() response = self.client.post(self.get_url(view.id), data={"starred": True}) diff --git a/tests/sentry/issues/endpoints/test_organization_group_search_view_starred_order.py b/tests/sentry/issues/endpoints/test_organization_group_search_view_starred_order.py index 7cb63bd0d17ea5..8a5f0b066d1f82 100644 --- a/tests/sentry/issues/endpoints/test_organization_group_search_view_starred_order.py +++ b/tests/sentry/issues/endpoints/test_organization_group_search_view_starred_order.py @@ -10,7 +10,7 @@ class OrganizationGroupSearchViewStarredOrderEndpointTest(APITestCase): endpoint = "sentry-api-0-organization-group-search-view-starred-order" - def setUp(self): + def setUp(self) -> None: super().setUp() self.login_as(user=self.user) self.user_2 = self.create_user() @@ -58,7 +58,7 @@ def setUp(self): visibility=GroupSearchViewVisibility.ORGANIZATION, ) - def star_views(self, view_ids: list[int]): + def star_views(self, view_ids: list[int]) -> None: for idx, view_id in enumerate(view_ids): GroupSearchViewStarred.objects.create( organization=self.organization, @@ -68,7 +68,7 @@ def star_views(self, view_ids: list[int]): ) @with_feature("organizations:issue-stream-custom-views") - def test_simple_reordering(self): + def test_simple_reordering(self) -> None: self.star_views([self.views[0].id, self.views[1].id, self.views[2].id]) new_order = [self.views[2].id, self.views[0].id, self.views[1].id] @@ -92,7 +92,7 @@ def test_simple_reordering(self): assert starred_views[2].position == 2 @with_feature("organizations:issue-stream-custom-views") - def test_same_order_reordering(self): + def test_same_order_reordering(self) -> None: original_order = [self.views[0].id, self.views[1].id, self.views[2].id] self.star_views(original_order) @@ -116,7 +116,7 @@ def test_same_order_reordering(self): assert starred_views[2].position == 2 @with_feature("organizations:issue-stream-custom-views") - def reordering_with_shared_views(self): + def reordering_with_shared_views(self) -> None: self.star_views([self.views[0].id, self.views[1].id, self.views[2].id, self.shared_view.id]) new_order = [self.shared_view.id, self.views[2].id, self.views[0].id, self.views[1].id] @@ -143,7 +143,7 @@ def reordering_with_shared_views(self): assert starred_views[3].position == 3 @with_feature("organizations:issue-stream-custom-views") - def test_empty_starred_list(self): + def test_empty_starred_list(self) -> None: response = self.client.put(self.url, data={"view_ids": []}, format="json") assert response.status_code == 204 @@ -154,7 +154,7 @@ def test_empty_starred_list(self): ).exists() @with_feature("organizations:issue-stream-custom-views") - def test_error_on_fewer_views_than_starred_views(self): + def test_error_on_fewer_views_than_starred_views(self) -> None: self.star_views([self.views[0].id, self.views[1].id, self.views[2].id]) response = self.client.put( @@ -164,7 +164,7 @@ def test_error_on_fewer_views_than_starred_views(self): assert response.status_code == 400 @with_feature("organizations:issue-stream-custom-views") - def test_error_on_more_views_than_starred_views(self): + def test_error_on_more_views_than_starred_views(self) -> None: self.star_views([self.views[0].id, self.views[1].id]) response = self.client.put( @@ -176,7 +176,7 @@ def test_error_on_more_views_than_starred_views(self): assert response.status_code == 400 @with_feature("organizations:issue-stream-custom-views") - def test_error_on_duplicate_view_ids(self): + def test_error_on_duplicate_view_ids(self) -> None: view_ids = [self.views[0].id, self.views[1].id, self.views[1].id] response = self.client.put(self.url, data={"view_ids": view_ids}, format="json") @@ -192,7 +192,7 @@ def test_error_on_duplicate_view_ids(self): class OrganizationGroupSearchViewStarredOrderTransactionTest(TransactionTestCase): endpoint = "sentry-api-0-organization-group-search-view-starred-order" - def setUp(self): + def setUp(self) -> None: super().setUp() self.login_as(user=self.user) @@ -209,7 +209,7 @@ def setUp(self): ) @with_feature("organizations:issue-stream-custom-views") - def test_nonexistent_view_id(self): + def test_nonexistent_view_id(self) -> None: non_existent_id = 373737 view_ids = [self.view.id, non_existent_id] diff --git a/tests/sentry/issues/endpoints/test_organization_group_search_views_starred.py b/tests/sentry/issues/endpoints/test_organization_group_search_views_starred.py index 069d810d32c600..08d94d4af9b926 100644 --- a/tests/sentry/issues/endpoints/test_organization_group_search_views_starred.py +++ b/tests/sentry/issues/endpoints/test_organization_group_search_views_starred.py @@ -43,7 +43,7 @@ def create_view( ) return view - def star_view(self, user: User, view: GroupSearchView): + def star_view(self, user: User, view: GroupSearchView) -> None: GroupSearchViewStarred.objects.insert_starred_view( user_id=user.id, organization=self.organization, @@ -52,7 +52,7 @@ def star_view(self, user: User, view: GroupSearchView): @with_feature({"organizations:issue-stream-custom-views": True}) @with_feature({"organizations:global-views": True}) - def test_simple_case(self): + def test_simple_case(self) -> None: self.login_as(user=self.user) view_1 = self.create_view(user=self.user, name="Starred View 1", starred=True) view_2 = self.create_view(user=self.user, name="Starred View 2", starred=True) @@ -71,7 +71,7 @@ def test_simple_case(self): @with_feature({"organizations:issue-stream-custom-views": True}) @with_feature({"organizations:global-views": True}) - def test_views_starred_by_many_users(self): + def test_views_starred_by_many_users(self) -> None: user_1 = self.user user_2 = self.create_user() self.create_member(user=user_2, organization=self.organization) diff --git a/tests/sentry/issues/endpoints/test_organization_group_suspect_flags.py b/tests/sentry/issues/endpoints/test_organization_group_suspect_flags.py index c3e7913833dd3b..2b19a5f02d8dd5 100644 --- a/tests/sentry/issues/endpoints/test_organization_group_suspect_flags.py +++ b/tests/sentry/issues/endpoints/test_organization_group_suspect_flags.py @@ -8,15 +8,15 @@ class OrganizationGroupSuspectFlagsTestCase(APITestCase, SnubaTestCase): endpoint = "sentry-api-0-organization-group-suspect-flags" - def setUp(self): + def setUp(self) -> None: super().setUp() self.login_as(user=self.user) @property - def features(self): + def features(self) -> dict[str, bool]: return {"organizations:feature-flag-suspect-flags": True} - def test_get(self): + def test_get(self) -> None: today = datetime.datetime.now(tz=datetime.UTC) - datetime.timedelta(minutes=5) group = self.create_group( first_seen=today - datetime.timedelta(hours=1), @@ -55,19 +55,26 @@ def test_get(self): ] } - def test_get_no_flag_access(self): + def test_get_no_flag_access(self) -> None: """Does not have feature-flag access.""" group = self.create_group() response = self.client.get(f"/api/0/issues/{group.id}/suspect/flags/") assert response.status_code == 404 - def test_get_no_group(self): + def test_get_no_group(self) -> None: """Group not found.""" with self.feature(self.features): response = self.client.get("/api/0/issues/22/suspect/flags/") assert response.status_code == 404 - def _mock_event(self, ts, hash="a" * 32, group_id=None, project_id=1, flags=None): + def _mock_event( + self, + ts: datetime.datetime, + hash: str = "a" * 32, + group_id: int | None = None, + project_id: int = 1, + flags: list[dict[str, object]] | None = None, + ) -> None: self.snuba_insert( ( 2, diff --git a/tests/sentry/issues/endpoints/test_organization_group_suspect_tags.py b/tests/sentry/issues/endpoints/test_organization_group_suspect_tags.py index 2a9ae6eb884ec1..3758f2f24a3d58 100644 --- a/tests/sentry/issues/endpoints/test_organization_group_suspect_tags.py +++ b/tests/sentry/issues/endpoints/test_organization_group_suspect_tags.py @@ -8,15 +8,15 @@ class OrganizationGroupSuspectTagsTestCase(APITestCase, SnubaTestCase): endpoint = "sentry-api-0-organization-group-suspect-tags" - def setUp(self): + def setUp(self) -> None: super().setUp() self.login_as(user=self.user) @property - def features(self): + def features(self) -> dict[str, bool]: return {"organizations:issues-suspect-tags": True} - def test_get(self): + def test_get(self) -> None: today = datetime.datetime.now(tz=datetime.UTC) - datetime.timedelta(minutes=5) group = self.create_group( first_seen=today - datetime.timedelta(hours=1), @@ -49,13 +49,13 @@ def test_get(self): ] } - def test_get_no_tag_access(self): + def test_get_no_tag_access(self) -> None: """Does not have feature-tag access.""" group = self.create_group() response = self.client.get(f"/api/0/issues/{group.id}/suspect/tags/") assert response.status_code == 404 - def test_get_no_group(self): + def test_get_no_group(self) -> None: """Group not found.""" with self.feature(self.features): response = self.client.get("/api/0/issues/22/suspect/tags/") diff --git a/tests/sentry/issues/endpoints/test_organization_issue_metrics.py b/tests/sentry/issues/endpoints/test_organization_issue_metrics.py index 31403521f23ca7..d78c052918017c 100644 --- a/tests/sentry/issues/endpoints/test_organization_issue_metrics.py +++ b/tests/sentry/issues/endpoints/test_organization_issue_metrics.py @@ -9,12 +9,12 @@ class OrganizationIssueMetricsTestCase(APITestCase): endpoint = "sentry-api-0-organization-issue-metrics" - def setUp(self): + def setUp(self) -> None: super().setUp() self.login_as(user=self.user) self.url = reverse(self.endpoint, args=(self.organization.slug,)) - def test_get_errors(self): + def test_get_errors(self) -> None: project1 = self.create_project(teams=[self.team], slug="foo") project2 = self.create_project(teams=[self.team], slug="bar") one = self.create_release(project1, version="1.0.0") @@ -110,7 +110,7 @@ def test_get_errors(self): }, ] - def test_get_issues_by_project(self): + def test_get_issues_by_project(self) -> None: """Assert the project filter works.""" project1 = self.create_project(teams=[self.team], slug="foo") project2 = self.create_project(teams=[self.team], slug="bar") @@ -173,7 +173,7 @@ def test_get_issues_by_project(self): }, ] - def test_get_feedback(self): + def test_get_feedback(self) -> None: project1 = self.create_project(teams=[self.team], slug="foo") project2 = self.create_project(teams=[self.team], slug="bar") @@ -245,31 +245,31 @@ def test_get_feedback(self): }, ] - def test_get_too_much_granularity(self): + def test_get_too_much_granularity(self) -> None: response = self.client.get(self.url + "?statsPeriod=14d&interval=1001") assert response.status_code == 400 assert response.json() == { "detail": "The specified granularity is too precise. Increase your interval." } - def test_get_invalid_interval(self): + def test_get_invalid_interval(self) -> None: response = self.client.get(self.url + "?interval=foo") assert response.status_code == 400 assert response.json() == {"detail": "Could not parse interval value."} - def test_get_zero_interval(self): + def test_get_zero_interval(self) -> None: response = self.client.get(self.url + "?interval=0") assert response.status_code == 400 assert response.json() == {"detail": "Interval must be greater than 1000 milliseconds."} - def test_get_invalid_category(self): + def test_get_invalid_category(self) -> None: response = self.client.get(self.url + "?category=foo") assert response.status_code == 400 assert response.json() == { "detail": "Invalid issue category. Valid options are 'issue' and 'feedback'." } - def test_other_grouping(self): + def test_other_grouping(self) -> None: project1 = self.create_project(teams=[self.team], slug="foo") project2 = self.create_project(teams=[self.team], slug="bar") one = self.create_release(project1, version="1.0.0") diff --git a/tests/sentry/issues/test_suspect_flags.py b/tests/sentry/issues/test_suspect_flags.py index 57eea1aadc250a..60f1c7d0752167 100644 --- a/tests/sentry/issues/test_suspect_flags.py +++ b/tests/sentry/issues/test_suspect_flags.py @@ -11,7 +11,14 @@ class SnubaTest(TestCase, SnubaTestCase): - def mock_event(self, ts, hash="a" * 32, group_id=None, project_id=1, flags=None): + def mock_event( + self, + ts: datetime.datetime, + hash: str = "a" * 32, + group_id: int | None = None, + project_id: int = 1, + flags: list[dict[str, object]] | None = None, + ) -> None: self.snuba_insert( ( 2, @@ -33,7 +40,7 @@ def mock_event(self, ts, hash="a" * 32, group_id=None, project_id=1, flags=None) ) ) - def test_query_baseline_set(self): + def test_query_baseline_set(self) -> None: before = datetime.datetime.now(tz=datetime.UTC) - datetime.timedelta(hours=1) today = before + datetime.timedelta(hours=1) later = today + datetime.timedelta(hours=1) @@ -60,7 +67,7 @@ def test_query_baseline_set(self): ) assert results == [("key", "false", 1), ("key", "true", 1), ("other", "false", 2)] - def test_query_selection_set(self): + def test_query_selection_set(self) -> None: before = datetime.datetime.now(tz=datetime.UTC) - datetime.timedelta(hours=1) today = before + datetime.timedelta(hours=1) later = today + datetime.timedelta(hours=1) @@ -87,7 +94,7 @@ def test_query_selection_set(self): results = query_selection_set(1, 1, before, later, environments=[], group_id=1) assert results == [("key", "true", 1), ("other", "false", 1)] - def test_get_suspect_flag_scores(self): + def test_get_suspect_flag_scores(self) -> None: before = datetime.datetime.now(tz=datetime.UTC) - datetime.timedelta(hours=1) today = before + datetime.timedelta(hours=1) later = today + datetime.timedelta(hours=1) diff --git a/tests/sentry/issues/test_suspect_tags.py b/tests/sentry/issues/test_suspect_tags.py index d54d6611943011..abbebb37d0ca09 100644 --- a/tests/sentry/issues/test_suspect_tags.py +++ b/tests/sentry/issues/test_suspect_tags.py @@ -33,7 +33,7 @@ def mock_event(self, ts, hash="a" * 32, group_id=None, project_id=1, tags=None): ) ) - def test_query_baseline_set(self): + def test_query_baseline_set(self) -> None: before = datetime.datetime.now(tz=datetime.UTC) - datetime.timedelta(hours=1) today = before + datetime.timedelta(hours=1) later = today + datetime.timedelta(hours=1) @@ -46,7 +46,7 @@ def test_query_baseline_set(self): ) assert results == [("key", "false", 1), ("key", "true", 1), ("other", "false", 2)] - def test_query_selection_set(self): + def test_query_selection_set(self) -> None: before = datetime.datetime.now(tz=datetime.UTC) - datetime.timedelta(hours=1) today = before + datetime.timedelta(hours=1) later = today + datetime.timedelta(hours=1) @@ -57,7 +57,7 @@ def test_query_selection_set(self): results = query_selection_set(1, 1, before, later, environments=[], group_id=1) assert results == [("key", "true", 1), ("other", "false", 1)] - def test_get_suspect_tag_scores(self): + def test_get_suspect_tag_scores(self) -> None: before = datetime.datetime.now(tz=datetime.UTC) - datetime.timedelta(hours=1) today = before + datetime.timedelta(hours=1) later = today + datetime.timedelta(hours=1) From 91dce7b4af58e250e0acf6252d567cd4bdcc65d8 Mon Sep 17 00:00:00 2001 From: anthony sottile Date: Mon, 21 Apr 2025 15:13:47 -0400 Subject: [PATCH 2/2] ref: slight improvement to auto generated types --- .../endpoints/test_organization_group_suspect_flags.py | 8 +++++++- tests/sentry/issues/test_suspect_flags.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/sentry/issues/endpoints/test_organization_group_suspect_flags.py b/tests/sentry/issues/endpoints/test_organization_group_suspect_flags.py index 2b19a5f02d8dd5..4cac4734cb9baf 100644 --- a/tests/sentry/issues/endpoints/test_organization_group_suspect_flags.py +++ b/tests/sentry/issues/endpoints/test_organization_group_suspect_flags.py @@ -1,10 +1,16 @@ import datetime import time import uuid +from typing import TypedDict from sentry.testutils.cases import APITestCase, SnubaTestCase +class _FlagResult(TypedDict): + flag: str + result: bool + + class OrganizationGroupSuspectFlagsTestCase(APITestCase, SnubaTestCase): endpoint = "sentry-api-0-organization-group-suspect-flags" @@ -73,7 +79,7 @@ def _mock_event( hash: str = "a" * 32, group_id: int | None = None, project_id: int = 1, - flags: list[dict[str, object]] | None = None, + flags: list[_FlagResult] | None = None, ) -> None: self.snuba_insert( ( diff --git a/tests/sentry/issues/test_suspect_flags.py b/tests/sentry/issues/test_suspect_flags.py index 60f1c7d0752167..a5fc4e40243fbc 100644 --- a/tests/sentry/issues/test_suspect_flags.py +++ b/tests/sentry/issues/test_suspect_flags.py @@ -1,6 +1,7 @@ import datetime import time import uuid +from typing import TypedDict from sentry.issues.suspect_flags import ( get_suspect_flag_scores, @@ -10,6 +11,11 @@ from sentry.testutils.cases import SnubaTestCase, TestCase +class _FlagResult(TypedDict): + flag: str + result: bool + + class SnubaTest(TestCase, SnubaTestCase): def mock_event( self, @@ -17,7 +23,7 @@ def mock_event( hash: str = "a" * 32, group_id: int | None = None, project_id: int = 1, - flags: list[dict[str, object]] | None = None, + flags: list[_FlagResult] | None = None, ) -> None: self.snuba_insert( (