Browse Source

chore(typing): Set 9 (#68508)

```
src/sentry/search/events/datasets/function_aliases.py:124: error: Function is missing a type annotation  [no-untyped-def]
src/sentry/search/events/datasets/function_aliases.py:275: error: Function is missing a return type annotation  [no-untyped-def]
src/sentry/search/events/datasets/function_aliases.py:329: error: Function is missing a return type annotation  [no-untyped-def]
src/sentry/search/events/datasets/function_aliases.py:348: error: Function is missing a return type annotation  [no-untyped-def]
src/sentry/search/events/datasets/field_aliases.py:87: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
src/sentry/search/events/datasets/field_aliases.py:140: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
src/sentry/search/events/datasets/spans_metrics.py:969: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
Found 7 errors in 3 files (checked 5606 source files)
```

---------

Co-authored-by: Joshua Ferge <josh.ferge@sentry.io>
Armen Zambrano G 11 months ago
parent
commit
ce5ca0edab

+ 1 - 0
pyproject.toml

@@ -606,6 +606,7 @@ module = [
     "sentry.relay.config.metric_extraction",
     "sentry.reprocessing2",
     "sentry.runner.*",
+    "sentry.search.events.datasets.*",
     "sentry.snuba.metrics.extraction",
     "sentry.tasks.commit_context",
     "sentry.tasks.on_demand_metrics",

+ 2 - 2
src/sentry/search/events/datasets/field_aliases.py

@@ -84,7 +84,7 @@ def resolve_project_slug_alias(builder: builder.QueryBuilder, alias: str) -> Sel
     return AliasedExpression(exp=builder.column("project_id"), alias=alias)
 
 
-def resolve_span_module(builder, alias: str) -> SelectType:
+def resolve_span_module(builder: builder.QueryBuilder, alias: str) -> SelectType:
     OP_MAPPING = {
         "db.redis": "cache",
         "db.sql.room": "other",
@@ -137,7 +137,7 @@ def resolve_device_class(builder: builder.QueryBuilder, alias: str) -> SelectTyp
     )
 
 
-def resolve_precise_timestamp(timestamp_column, ms_column, alias: str) -> SelectType:
+def resolve_precise_timestamp(timestamp_column: str, ms_column: str, alias: str) -> SelectType:
     return Function(
         "plus",
         [

+ 6 - 4
src/sentry/search/events/datasets/function_aliases.py

@@ -121,7 +121,7 @@ def resolve_project_threshold_config(
         constants.PROJECT_THRESHOLD_OVERRIDE_CONFIG_INDEX_ALIAS,
     )
 
-    def _project_threshold_config(alias=None):
+    def _project_threshold_config(alias: str | None = None) -> SelectType:
         if project_threshold_config_keys and project_threshold_config_values:
             return Function(
                 "if",
@@ -277,7 +277,7 @@ def resolve_metrics_layer_percentile(
     alias: str,
     resolve_mri: Callable[[str], Column],
     fixed_percentile: float | None = None,
-):
+) -> SelectType:
     # TODO: rename to just resolve_metrics_percentile once the non layer code can be retired
     if fixed_percentile is None:
         fixed_percentile = args["percentile"]
@@ -326,7 +326,9 @@ def resolve_division(
     )
 
 
-def resolve_rounded_timestamp(interval: int, alias: str, timestamp_column: str = "timestamp"):
+def resolve_rounded_timestamp(
+    interval: int, alias: str, timestamp_column: str = "timestamp"
+) -> SelectType:
     return Function(
         "toUInt32",
         [
@@ -351,7 +353,7 @@ def resolve_random_samples(
     offset: int,
     limit: int,
     size: int = 1,
-):
+) -> SelectType:
     seed_str = f"{offset}-{limit}"
     seed = fnv1a_32(seed_str.encode("utf-8"))
     return Function(

+ 6 - 4
src/sentry/search/events/datasets/spans_metrics.py

@@ -853,9 +853,11 @@ class SpansMetricsDatasetConfig(DatasetConfig):
                         condition,
                     ],
                 ),
-                args["interval"]
-                if interval is None
-                else Function("divide", [args["interval"], interval]),
+                (
+                    args["interval"]
+                    if interval is None
+                    else Function("divide", [args["interval"], interval])
+                ),
             ],
             alias,
         )
@@ -966,7 +968,7 @@ class SpansMetricsLayerDatasetConfig(DatasetConfig):
         self.builder = builder
         self.total_span_duration: float | None = None
 
-    def resolve_mri(self, value) -> Column:
+    def resolve_mri(self, value: str) -> Column:
         """Given the public facing column name resolve it to the MRI and return a Column"""
         # If the query builder has not detected a transaction use the light self time metric to get a performance boost
         if value == "span.self_time" and not self.builder.has_transaction: