Skip to content

Commit

Permalink
typing(seer): Type grouping ingest modules and test_seer (#79277)
Browse files Browse the repository at this point in the history
  • Loading branch information
armenzg authored Oct 17, 2024
1 parent 8f8d1d6 commit f54f66b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,7 @@ module = [
"sentry.eventtypes.error",
"sentry.grouping.component",
"sentry.grouping.fingerprinting",
"sentry.grouping.ingest.metrics",
"sentry.grouping.ingest.utils",
"sentry.grouping.ingest.*",
"sentry.grouping.parameterization",
"sentry.hybridcloud.*",
"sentry.ingest.slicing",
Expand Down Expand Up @@ -537,6 +536,7 @@ module = [
"sentry_plugins.base",
"tests.sentry.deletions.test_group",
"tests.sentry.event_manager.test_event_manager",
"tests.sentry.grouping.ingest.test_seer",
"tests.sentry.grouping.test_fingerprinting",
"tests.sentry.hybridcloud.*",
"tests.sentry.issues",
Expand Down
28 changes: 14 additions & 14 deletions tests/sentry/grouping/ingest/test_seer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class ShouldCallSeerTest(TestCase):
def setUp(self):
def setUp(self) -> None:
self.event_data = {
"title": "FailedToFetchError('Charlie didn't bring the ball back')",
"exception": {
Expand Down Expand Up @@ -45,7 +45,7 @@ def setUp(self):
self.variants = self.event.get_grouping_variants()
self.primary_hashes = self.event.get_hashes()

def test_obeys_feature_enablement_check(self):
def test_obeys_feature_enablement_check(self) -> None:
for backfill_completed_option, expected_result in [(None, False), (11211231, True)]:
self.project.update_option(
"sentry:similarity_backfill_completed", backfill_completed_option
Expand All @@ -54,7 +54,7 @@ def test_obeys_feature_enablement_check(self):
should_call_seer_for_grouping(self.event, self.variants) is expected_result
), f"Case {backfill_completed_option} failed."

def test_obeys_content_filter(self):
def test_obeys_content_filter(self) -> None:
self.project.update_option("sentry:similarity_backfill_completed", int(time()))

for content_eligibility, expected_result in [(True, True), (False, False)]:
Expand All @@ -64,21 +64,21 @@ def test_obeys_content_filter(self):
):
assert should_call_seer_for_grouping(self.event, self.variants) is expected_result

def test_obeys_global_seer_killswitch(self):
def test_obeys_global_seer_killswitch(self) -> None:
self.project.update_option("sentry:similarity_backfill_completed", int(time()))

for killswitch_enabled, expected_result in [(True, False), (False, True)]:
with override_options({"seer.global-killswitch.enabled": killswitch_enabled}):
assert should_call_seer_for_grouping(self.event, self.variants) is expected_result

def test_obeys_similarity_service_killswitch(self):
def test_obeys_similarity_service_killswitch(self) -> None:
self.project.update_option("sentry:similarity_backfill_completed", int(time()))

for killswitch_enabled, expected_result in [(True, False), (False, True)]:
with override_options({"seer.similarity-killswitch.enabled": killswitch_enabled}):
assert should_call_seer_for_grouping(self.event, self.variants) is expected_result

def test_obeys_project_specific_killswitch(self):
def test_obeys_project_specific_killswitch(self) -> None:
self.project.update_option("sentry:similarity_backfill_completed", int(time()))

for blocked_projects, expected_result in [([self.project.id], False), ([], True)]:
Expand All @@ -87,7 +87,7 @@ def test_obeys_project_specific_killswitch(self):
):
assert should_call_seer_for_grouping(self.event, self.variants) is expected_result

def test_obeys_global_ratelimit(self):
def test_obeys_global_ratelimit(self) -> None:
self.project.update_option("sentry:similarity_backfill_completed", int(time()))

for ratelimit_enabled, expected_result in [(True, False), (False, True)]:
Expand All @@ -99,7 +99,7 @@ def test_obeys_global_ratelimit(self):
):
assert should_call_seer_for_grouping(self.event, self.variants) is expected_result

def test_obeys_project_ratelimit(self):
def test_obeys_project_ratelimit(self) -> None:
self.project.update_option("sentry:similarity_backfill_completed", int(time()))

for ratelimit_enabled, expected_result in [(True, False), (False, True)]:
Expand All @@ -113,7 +113,7 @@ def test_obeys_project_ratelimit(self):
):
assert should_call_seer_for_grouping(self.event, self.variants) is expected_result

def test_obeys_circuit_breaker(self):
def test_obeys_circuit_breaker(self) -> None:
self.project.update_option("sentry:similarity_backfill_completed", int(time()))

for request_allowed, expected_result in [(True, True), (False, False)]:
Expand All @@ -123,7 +123,7 @@ def test_obeys_circuit_breaker(self):
):
assert should_call_seer_for_grouping(self.event, self.variants) is expected_result

def test_obeys_customized_fingerprint_check(self):
def test_obeys_customized_fingerprint_check(self) -> None:
self.project.update_option("sentry:similarity_backfill_completed", int(time()))

default_fingerprint_event = Event(
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_obeys_customized_fingerprint_check(self):


class GetSeerSimilarIssuesTest(TestCase):
def setUp(self):
def setUp(self) -> None:
self.existing_event = save_new_event({"message": "Dogs are great!"}, self.project)
assert self.existing_event.get_primary_hash() == "04e89719410791836f0a0bbf03bf0d2e"
# In real life just filtering on group id wouldn't be enough to guarantee us a single,
Expand All @@ -182,7 +182,7 @@ def setUp(self):
assert self.new_event.get_primary_hash() == "3f11319f08263b2ee1e654779742955a"

@patch("sentry.grouping.ingest.seer.get_similarity_data_from_seer", return_value=[])
def test_sends_expected_data_to_seer(self, mock_get_similarity_data: MagicMock):
def test_sends_expected_data_to_seer(self, mock_get_similarity_data: MagicMock) -> None:
type = "FailedToFetchError"
value = "Charlie didn't bring the ball back"
context_line = f"raise {type}('{value}')"
Expand Down Expand Up @@ -226,7 +226,7 @@ def test_sends_expected_data_to_seer(self, mock_get_similarity_data: MagicMock):
}
)

def test_returns_metadata_and_grouphash_if_sufficiently_close_group_found(self):
def test_returns_metadata_and_grouphash_if_sufficiently_close_group_found(self) -> None:
seer_result_data = SeerSimilarIssueData(
parent_hash=NonNone(self.existing_event.get_primary_hash()),
parent_group_id=NonNone(self.existing_event.group_id),
Expand All @@ -248,7 +248,7 @@ def test_returns_metadata_and_grouphash_if_sufficiently_close_group_found(self):
self.existing_event_grouphash,
)

def test_returns_no_grouphash_and_empty_metadata_if_no_similar_group_found(self):
def test_returns_no_grouphash_and_empty_metadata_if_no_similar_group_found(self) -> None:
expected_metadata = {
"similarity_model_version": SEER_SIMILARITY_MODEL_VERSION,
"results": [],
Expand Down

0 comments on commit f54f66b

Please sign in to comment.