Просмотр исходного кода

ref: fix all [list-item] mypy errors in ignored files (#75498)

depends on https://github.com/getsentry/sentry/pull/75496

<!-- Describe your PR here. -->
anthony sottile 7 месяцев назад
Родитель
Сommit
61adfb9bd0

+ 0 - 1
pyproject.toml

@@ -468,7 +468,6 @@ disable_error_code = [
     "dict-item",
     "has-type",
     "index",
-    "list-item",
     "misc",
     "operator",
     "override",

+ 2 - 4
src/sentry/api/endpoints/organization_events_facets_performance.py

@@ -510,7 +510,7 @@ def query_facet_performance_key_histogram(
     num_buckets_per_key: int,
     limit: int,
     referrer: str,
-    aggregate_column: str | None = None,
+    aggregate_column: str,
     filter_query: str | None = None,
 ) -> dict:
     precision = 0
@@ -518,9 +518,7 @@ def query_facet_performance_key_histogram(
     tag_values = [x["tags_value"] for x in top_tags]
 
     results = discover.histogram_query(
-        fields=[
-            aggregate_column,
-        ],
+        fields=[aggregate_column],
         user_query=filter_query,
         params=params,
         num_buckets=num_buckets_per_key,

+ 4 - 0
src/sentry/integrations/slack/views/link_identity.py

@@ -1,5 +1,6 @@
 import logging
 
+from django.contrib.auth.models import AnonymousUser
 from django.core.signing import BadSignature, SignatureExpired
 from django.db import IntegrityError
 from django.http import Http404, HttpRequest, HttpResponse
@@ -104,6 +105,9 @@ class SlackLinkIdentityView(BaseView):
         )
 
     def post(self, request: Request, *args, **kwargs) -> HttpResponse:
+        if isinstance(request.user, AnonymousUser):
+            return HttpResponse(status=401)
+
         try:
             params_dict = kwargs["params"]
             params = IdentityParams(

+ 1 - 1
src/sentry/integrations/slack/webhooks/action.py

@@ -122,7 +122,7 @@ def update_group(
     )
 
 
-def get_rule(slack_request: SlackActionRequest) -> Group | None:
+def get_rule(slack_request: SlackActionRequest) -> Rule | None:
     """Get the rule that fired"""
     rule_id = slack_request.callback_data.get("rule")
     if not rule_id:

+ 1 - 0
src/sentry/middleware/ratelimit.py

@@ -115,6 +115,7 @@ class RatelimitMiddleware:
                         ),
                         status=429,
                     )
+                    assert request.method is not None
                     return apply_cors_headers(
                         request=request, response=response, allowed_methods=[request.method]
                     )

+ 1 - 1
src/sentry/scim/endpoints/utils.py

@@ -23,8 +23,8 @@ class SCIMApiError(APIException):
         transaction = sentry_sdk.Scope.get_current_scope().transaction
         if transaction is not None:
             transaction.set_tag("http.status_code", status_code)
+        super().__init__({"schemas": [SCIM_API_ERROR], "detail": detail})
         self.status_code = status_code
-        self.detail = {"schemas": [SCIM_API_ERROR], "detail": detail}
 
 
 class SCIMFilterError(ValueError):

+ 4 - 2
src/sentry/search/events/fields.py

@@ -95,7 +95,9 @@ class PseudoField:
         ), f"{self.name}: only one of expression, expression_fn is allowed"
 
 
-def project_threshold_config_expression(organization_id, project_ids):
+def project_threshold_config_expression(
+    organization_id: int | None, project_ids: list[int] | None
+) -> list[object]:
     """
     This function returns a column with the threshold and threshold metric
     for each transaction based on project level settings. If no project level
@@ -179,7 +181,7 @@ def project_threshold_config_expression(organization_id, project_ids):
         PROJECT_THRESHOLD_OVERRIDE_CONFIG_INDEX_ALIAS,
     ]
 
-    project_config_query = (
+    project_config_query: list[object] = (
         [
             "if",
             [

+ 1 - 1
src/sentry/search/events/filter.py

@@ -139,7 +139,7 @@ def _environment_filter_converter(
     params: Mapping[str, int | str | datetime] | None,
 ):
     # conditions added to env_conditions are OR'd
-    env_conditions = []
+    env_conditions: list[list[object]] = []
     value = search_filter.value.value
     values = set(value if isinstance(value, (list, tuple)) else [value])
     # the "no environment" environment is null in snuba

+ 1 - 1
src/sentry/testutils/cases.py

@@ -2204,7 +2204,7 @@ class MetricsEnhancedPerformanceTestCase(BaseMetricsLayerTestCase, TestCase):
 
     def store_span_metric(
         self,
-        value: dict[str, int] | list[int] | int,
+        value: dict[str, int] | list[int] | list[dict[str, int]] | int,
         metric: str = "span.self_time",
         internal_metric: str | None = None,
         entity: str | None = None,