Browse Source

ref: fix typing on a handful of endpoints (#62281)

<!-- Describe your PR here. -->
anthony sottile 1 year ago
parent
commit
265c0aa7ca

+ 0 - 3
pyproject.toml

@@ -148,7 +148,6 @@ module = [
     "sentry.api.endpoints.chunk",
     "sentry.api.endpoints.codeowners",
     "sentry.api.endpoints.codeowners.index",
-    "sentry.api.endpoints.event_apple_crash_report",
     "sentry.api.endpoints.event_attachments",
     "sentry.api.endpoints.group_details",
     "sentry.api.endpoints.group_event_details",
@@ -158,7 +157,6 @@ module = [
     "sentry.api.endpoints.group_integration_details",
     "sentry.api.endpoints.group_integrations",
     "sentry.api.endpoints.group_notes",
-    "sentry.api.endpoints.group_similar_issues",
     "sentry.api.endpoints.group_tagkey_details",
     "sentry.api.endpoints.group_tagkey_values",
     "sentry.api.endpoints.group_tags",
@@ -173,7 +171,6 @@ module = [
     "sentry.api.endpoints.integrations.sentry_apps.requests",
     "sentry.api.endpoints.integrations.sentry_apps.stats.details",
     "sentry.api.endpoints.internal.mail",
-    "sentry.api.endpoints.notifications.notification_actions_available",
     "sentry.api.endpoints.notifications.notification_actions_details",
     "sentry.api.endpoints.organization_code_mapping_codeowners",
     "sentry.api.endpoints.organization_code_mapping_details",

+ 12 - 8
src/sentry/api/endpoints/event_apple_crash_report.py

@@ -1,4 +1,5 @@
 from django.http import HttpResponse, StreamingHttpResponse
+from django.http.response import HttpResponseBase
 from rest_framework.request import Request
 
 from sentry import eventstore
@@ -18,7 +19,7 @@ class EventAppleCrashReportEndpoint(ProjectEndpoint):
         "GET": ApiPublishStatus.UNKNOWN,
     }
 
-    def get(self, request: Request, project, event_id) -> HttpResponse:
+    def get(self, request: Request, project, event_id) -> HttpResponseBase:
         """
         Retrieve an Apple Crash Report from an event
         `````````````````````````````````````````````
@@ -47,12 +48,15 @@ class EventAppleCrashReportEndpoint(ProjectEndpoint):
             )
         )
 
-        response = HttpResponse(apple_crash_report_string, content_type="text/plain")
-
         if request.GET.get("download") is not None:
             filename = "{}{}.crash".format(event.event_id, symbolicated and "-symbolicated" or "")
-            response = StreamingHttpResponse(apple_crash_report_string, content_type="text/plain")
-            response["Content-Length"] = len(apple_crash_report_string)
-            response["Content-Disposition"] = 'attachment; filename="%s"' % filename
-
-        return response
+            return StreamingHttpResponse(
+                apple_crash_report_string,
+                content_type="text/plain",
+                headers={
+                    "Content-Length": len(apple_crash_report_string),
+                    "Content-Disposition": f'attachment; filename="{filename}"',
+                },
+            )
+        else:
+            return HttpResponse(apple_crash_report_string, content_type="text/plain")

+ 5 - 3
src/sentry/api/endpoints/group_similar_issues.py

@@ -28,9 +28,11 @@ class GroupSimilarIssuesEndpoint(GroupEndpoint):
     def get(self, request: Request, group) -> Response:
         features = similarity.features
 
-        limit = request.GET.get("limit", None)
-        if limit is not None:
-            limit = int(limit) + 1  # the target group will always be included
+        limit_s = request.GET.get("limit", None)
+        if limit_s is not None:
+            limit: int | None = int(limit_s) + 1  # the target group will always be included
+        else:
+            limit = None
 
         group_ids = []
         group_scores = []

+ 1 - 1
src/sentry/api/endpoints/notifications/notification_actions_available.py

@@ -23,7 +23,7 @@ class NotificationActionsAvailableEndpoint(OrganizationEndpoint):
         Responds with a payload serialized directly from running the 'serialize_available' methods
         on the ActionRegistration objects within the NotificationAction registry.
         """
-        payload = {"actions": []}
+        payload: dict[str, list[dict[str, object]]] = {"actions": []}
         integrations = integration_service.get_integrations(
             organization_id=organization.id,
             status=ObjectStatus.ACTIVE,