Skip to content

Commit 5fc38a6

Browse files
committed
feat(typing): add possibly undefined check for issues team code
1 parent fa49fef commit 5fc38a6

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

pyproject.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ warn_unused_ignores = true
6666
warn_redundant_casts = true
6767
enable_error_code = ["ignore-without-code"]
6868

69-
enable_error_code = ["possibly-undefined"]
70-
71-
enable_error_code = ["possibly-undefined"]
7269

7370
[tool.django-stubs]
7471
django_settings_module = "sentry.conf.server_mypy"
@@ -655,3 +652,16 @@ module = [
655652
disallow_any_generics = true
656653
disallow_untyped_defs = true
657654
# end: stronger typing
655+
656+
# begin: possibly-undefined checks for issue team critical code
657+
[[tool.mypy.overrides]]
658+
module = [
659+
"sentry.issues.*",
660+
"sentry.tasks.post_process",
661+
"sentry.event_manager",
662+
"sentry.grouping.*",
663+
"sentry.tasks.store",
664+
"sentry.ingest.consumer.processors"
665+
]
666+
enable_error_code = ["possibly-undefined"]
667+
# end: possibly-undefined

src/sentry/issues/grouptype.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def add(self, group_type: type[GroupType]) -> None:
4949
raise ValueError(
5050
f"A group type with the type_id {group_type.type_id} has already been registered."
5151
)
52+
5253
self._registry[group_type.type_id] = group_type
5354
self._slug_lookup[group_type.slug] = group_type
5455
self._category_lookup[group_type.category].add(group_type.type_id)

src/sentry/issues/ingest.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ def materialize_metadata(occurrence: IssueOccurrence, event: Event) -> Occurrenc
137137
event_metadata["title"] = occurrence.issue_title
138138
event_metadata["value"] = occurrence.subtitle
139139
event_metadata["initial_priority"] = occurrence.initial_issue_priority
140-
141140
if occurrence.type == FeedbackGroup:
142141
# TODO: Should feedbacks be their own event type, so above call to event.get_event_medata
143142
# could populate this instead?
@@ -199,14 +198,14 @@ def save_issue_from_occurrence(
199198
metrics.incr("issues.issue.dropped.rate_limiting")
200199
return None
201200

202-
with sentry_sdk.start_span(
203-
op="issues.save_issue_from_occurrence.transaction"
204-
) as span, metrics.timer(
205-
"issues.save_issue_from_occurrence.transaction",
206-
tags={"platform": event.platform or "unknown", "type": occurrence.type.type_id},
207-
sample_rate=1.0,
208-
) as metric_tags, transaction.atomic(
209-
router.db_for_write(GroupHash)
201+
with (
202+
sentry_sdk.start_span(op="issues.save_issue_from_occurrence.transaction") as span,
203+
metrics.timer(
204+
"issues.save_issue_from_occurrence.transaction",
205+
tags={"platform": event.platform or "unknown", "type": occurrence.type.type_id},
206+
sample_rate=1.0,
207+
) as metric_tags,
208+
transaction.atomic(router.db_for_write(GroupHash)),
210209
):
211210
group, is_new = _save_grouphash_and_group(
212211
project, event, new_grouphash, **cast(Mapping[str, Any], issue_kwargs)

src/sentry/tasks/post_process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ def _get_replay_id(event):
10681068
kafka_payload = transform_event_for_linking_payload(replay_id, group_event)
10691069
except ValueError:
10701070
metrics.incr("post_process.process_replay_link.id_invalid")
1071+
return
10711072

10721073
publisher.publish(
10731074
"ingest-replay-events",

0 commit comments

Comments
 (0)