Skip to content

Commit 4874068

Browse files
committed
chore(issues): Expand stronger typing enforcement for issues
1 parent 565a7a8 commit 4874068

File tree

17 files changed

+46
-37
lines changed

17 files changed

+46
-37
lines changed

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,10 @@ module = [
577577
"sentry.buffer.base",
578578
"sentry.buffer.redis",
579579
"sentry.eventstore.reprocessing.redis",
580+
"sentry.grouping.ingest.metrics",
581+
"sentry.grouping.ingest.utils",
582+
"sentry.grouping.strategies",
583+
"sentry.grouping.strategies.message",
580584
"sentry.issues.analytics",
581585
"sentry.issues.apps",
582586
"sentry.issues.constants",
@@ -609,6 +613,7 @@ module = [
609613
"sentry.issues.update_inbox",
610614
"sentry.lang.java.processing",
611615
"sentry.llm.*",
616+
"sentry.mediators.token_exchange.util",
612617
"sentry.migrations.*",
613618
"sentry.nodestore.base",
614619
"sentry.nodestore.bigtable.backend",
@@ -620,6 +625,7 @@ module = [
620625
"sentry.reprocessing2",
621626
"sentry.runner.*",
622627
"sentry.snuba.metrics.extraction",
628+
"sentry.tasks.auto_remove_inbox",
623629
"sentry.tasks.commit_context",
624630
"sentry.tasks.on_demand_metrics",
625631
"sentry.tasks.reprocessing2",

src/sentry/grouping/api.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def get_config_dict(self, project: Project) -> GroupingConfig:
9696
"enhancements": self._get_enhancements(project),
9797
}
9898

99-
def _get_enhancements(self, project) -> str:
99+
def _get_enhancements(self, project: Project) -> str:
100100
enhancements = project.get_option("sentry:grouping_enhancements")
101101

102102
config_id = self._get_config_id(project)
@@ -121,14 +121,14 @@ def _get_enhancements(self, project) -> str:
121121
cache.set(cache_key, rv)
122122
return rv
123123

124-
def _get_config_id(self, project):
124+
def _get_config_id(self, project: Project):
125125
raise NotImplementedError
126126

127127

128128
class ProjectGroupingConfigLoader(GroupingConfigLoader):
129129
option_name: str # Set in subclasses
130130

131-
def _get_config_id(self, project):
131+
def _get_config_id(self, project: Project):
132132
return project.get_option(
133133
self.option_name,
134134
validate=lambda x: x in CONFIGURATIONS,
@@ -154,7 +154,7 @@ class BackgroundGroupingConfigLoader(GroupingConfigLoader):
154154

155155
cache_prefix = "background-grouping-enhancements:"
156156

157-
def _get_config_id(self, project):
157+
def _get_config_id(self, project: Project):
158158
return options.get("store.background-grouping-config-id")
159159

160160

@@ -176,7 +176,7 @@ def get_grouping_config_dict_for_event_data(data, project) -> GroupingConfig:
176176
return data.get("grouping_config") or get_grouping_config_dict_for_project(project)
177177

178178

179-
def get_default_enhancements(config_id=None) -> str:
179+
def get_default_enhancements(config_id: str | None = None) -> str:
180180
base: str | None = DEFAULT_GROUPING_ENHANCEMENTS_BASE
181181
if config_id is not None:
182182
base = CONFIGURATIONS[config_id].enhancements_base
@@ -200,7 +200,7 @@ def get_projects_default_fingerprinting_bases(
200200
return bases
201201

202202

203-
def get_default_grouping_config_dict(config_id=None) -> GroupingConfig:
203+
def get_default_grouping_config_dict(config_id: str | None = None) -> GroupingConfig:
204204
"""Returns the default grouping config."""
205205
if config_id is None:
206206
from sentry.projectoptions.defaults import DEFAULT_GROUPING_CONFIG
@@ -257,7 +257,7 @@ def get_fingerprinting_config_for_project(
257257
return rv
258258

259259

260-
def apply_server_fingerprinting(event, config, allow_custom_title=True):
260+
def apply_server_fingerprinting(event, config, allow_custom_title=True) -> None:
261261
client_fingerprint = event.get("fingerprint")
262262
rv = config.get_fingerprint_values_for_event(event)
263263
if rv is not None:
@@ -419,7 +419,9 @@ def sort_grouping_variants(variants: dict[str, BaseVariant]) -> tuple[KeyedVaria
419419
return flat_variants, hierarchical_variants
420420

421421

422-
def detect_synthetic_exception(event_data: NodeData, loaded_grouping_config: StrategyConfiguration):
422+
def detect_synthetic_exception(
423+
event_data: NodeData, loaded_grouping_config: StrategyConfiguration
424+
) -> None:
423425
"""Detect synthetic exception and write marker to event data
424426
425427
This only runs if detect_synthetic_exception_types is True, so

src/sentry/grouping/component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,5 @@ def as_dict(self):
176176
rv["values"].append(value)
177177
return rv
178178

179-
def __repr__(self):
179+
def __repr__(self) -> str:
180180
return f"GroupingComponent({self.id!r}, hint={self.hint!r}, contributes={self.contributes!r}, values={self.values!r})"

src/sentry/grouping/enhancer/actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def update_frame_components_contributions(
4040
) -> None:
4141
pass
4242

43-
def modify_stacktrace_state(self, state, rule):
43+
def modify_stacktrace_state(self, state, rule) -> None:
4444
pass
4545

4646
@property

src/sentry/grouping/enhancer/matchers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def __init__(self, inner: FrameMatch):
304304
def description(self) -> str:
305305
return f"[ {self.inner.description} ] |"
306306

307-
def _to_config_structure(self, version):
307+
def _to_config_structure(self, version) -> str:
308308
return f"[{self.inner._to_config_structure(version)}]|"
309309

310310
def matches_frame(self, frames, idx, exception_data, cache):
@@ -319,7 +319,7 @@ def __init__(self, inner: FrameMatch):
319319
def description(self) -> str:
320320
return f"| [ {self.inner.description} ]"
321321

322-
def _to_config_structure(self, version):
322+
def _to_config_structure(self, version) -> str:
323323
return f"|[{self.inner._to_config_structure(version)}]"
324324

325325
def matches_frame(self, frames, idx, exception_data, cache):

src/sentry/grouping/ingest/metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def record_hash_calculation_metrics(
2727
primary_hashes: CalculatedHashes,
2828
secondary_config: GroupingConfig,
2929
secondary_hashes: CalculatedHashes,
30-
):
30+
) -> None:
3131
has_secondary_hashes = len(extract_hashes(secondary_hashes)) > 0
3232

3333
if has_secondary_hashes:
@@ -93,7 +93,7 @@ def record_calculation_metric_with_result(
9393
metrics.incr("grouping.total_calculations", amount=2 if has_secondary_hashes else 1, tags=tags)
9494

9595

96-
def record_new_group_metrics(event: Event):
96+
def record_new_group_metrics(event: Event) -> None:
9797
metrics.incr(
9898
"group.created",
9999
skip_internal=True,

src/sentry/grouping/ingest/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def add_group_id_to_grouphashes(
4040
).update(group=group)
4141

4242

43-
def check_for_group_creation_load_shed(project: Project, event: Event):
43+
def check_for_group_creation_load_shed(project: Project, event: Event) -> None:
4444
"""
4545
Raise a `HashDiscarded` error if the load-shed killswitch is enabled
4646
"""

src/sentry/grouping/strategies/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def _import_all():
1+
def _import_all() -> None:
22
# The import order here is important due to cross dependencies
33
strategy_modules = [
44
"message",

src/sentry/grouping/strategies/message.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import Any
99

1010
import tiktoken
11+
from tiktoken.core import Encoding
1112

1213
from sentry import analytics
1314
from sentry.eventstore.models import Event
@@ -167,7 +168,7 @@
167168

168169
# UniqID logic
169170
@lru_cache(maxsize=1)
170-
def tiktoken_encoding():
171+
def tiktoken_encoding() -> Encoding:
171172
return tiktoken.get_encoding("cl100k_base")
172173

173174

src/sentry/grouping/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ def parse_fingerprint_var(value):
1515
return match.group(1)
1616

1717

18-
def is_default_fingerprint_var(value):
18+
def is_default_fingerprint_var(value) -> bool:
1919
return parse_fingerprint_var(value) == "default"
2020

2121

22-
def hash_from_values(values):
22+
def hash_from_values(values) -> str:
2323
result = md5()
2424
for value in values:
2525
result.update(force_bytes(value, errors="replace"))
2626
return result.hexdigest()
2727

2828

29-
def get_rule_bool(value):
29+
def get_rule_bool(value: str):
3030
if value:
3131
value = value.lower()
3232
if value in ("1", "yes", "true"):

0 commit comments

Comments
 (0)