From 23fed350e39c3cf6f9096e896bd2b158691a35c4 Mon Sep 17 00:00:00 2001 From: anthony sottile <103459774+asottile-sentry@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:16:43 -0400 Subject: [PATCH] ref: fix typing for tests in mypy 1.12.x (#79528) --- src/sentry/testutils/factories.py | 4 +--- tests/sentry/event_manager/grouping/test_assign_to_group.py | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sentry/testutils/factories.py b/src/sentry/testutils/factories.py index ce3245359d6e6..990082ef1134d 100644 --- a/src/sentry/testutils/factories.py +++ b/src/sentry/testutils/factories.py @@ -439,9 +439,7 @@ def create_team_membership(team, member=None, user=None, role=None): @staticmethod @assume_test_silo_mode(SiloMode.CONTROL) def create_api_key(organization, scope_list=None, **kwargs): - return ApiKey.objects.create( - organization_id=organization.id if organization else None, scope_list=scope_list - ) + return ApiKey.objects.create(organization_id=organization.id, scope_list=scope_list) @staticmethod @assume_test_silo_mode(SiloMode.CONTROL) diff --git a/tests/sentry/event_manager/grouping/test_assign_to_group.py b/tests/sentry/event_manager/grouping/test_assign_to_group.py index 3e2a5f863496b..8dbc4e2467c17 100644 --- a/tests/sentry/event_manager/grouping/test_assign_to_group.py +++ b/tests/sentry/event_manager/grouping/test_assign_to_group.py @@ -176,7 +176,9 @@ def get_results_from_saving_event( secondary_hash_calculated = calculate_secondary_hash_spy.call_count == 1 primary_hash = return_values["_calculate_primary_hashes_and_variants"][0][0][0] - primary_hash_found = bool(hash_search_result) and hash_search_result.hash == primary_hash + primary_hash_found = ( + hash_search_result is not None and hash_search_result.hash == primary_hash + ) new_group_created = create_group_spy.call_count == 1 @@ -203,7 +205,7 @@ def get_results_from_saving_event( secondary_hash = return_values["_calculate_secondary_hashes"][0][0] hashes_different = secondary_hash != primary_hash secondary_hash_found = ( - bool(hash_search_result) and hash_search_result.hash == secondary_hash + hash_search_result is not None and hash_search_result.hash == secondary_hash ) secondary_grouphash_existed_already = secondary_hash in existing_grouphashes secondary_grouphash_exists_now = secondary_hash in post_save_grouphashes