Browse Source

ref: Apply a few simpler typing fixes (#51509)

Markus Unterwaditzer 1 year ago
parent
commit
ef66ae7af5

+ 0 - 7
pyproject.toml

@@ -168,14 +168,10 @@ module = [
     "sentry.api.decorators",
     "sentry.api.endpoints.accept_organization_invite",
     "sentry.api.endpoints.accept_project_transfer",
-    "sentry.api.endpoints.admin_project_configs",
     "sentry.api.endpoints.api_application_details",
-    "sentry.api.endpoints.api_applications",
-    "sentry.api.endpoints.api_authorizations",
     "sentry.api.endpoints.api_tokens",
     "sentry.api.endpoints.artifact_lookup",
     "sentry.api.endpoints.auth_config",
-    "sentry.api.endpoints.auth_index",
     "sentry.api.endpoints.auth_login",
     "sentry.api.endpoints.avatar.doc_integration",
     "sentry.api.endpoints.avatar.organization",
@@ -183,7 +179,6 @@ module = [
     "sentry.api.endpoints.avatar.sentry_app",
     "sentry.api.endpoints.avatar.team",
     "sentry.api.endpoints.avatar.user",
-    "sentry.api.endpoints.broadcast_index",
     "sentry.api.endpoints.catchall",
     "sentry.api.endpoints.chunk",
     "sentry.api.endpoints.codeowners",
@@ -191,7 +186,6 @@ module = [
     "sentry.api.endpoints.codeowners.external_actor.team_details",
     "sentry.api.endpoints.codeowners.index",
     "sentry.api.endpoints.data_scrubbing_selector_suggestions",
-    "sentry.api.endpoints.debug_files",
     "sentry.api.endpoints.event_ai_suggested_fix",
     "sentry.api.endpoints.event_apple_crash_report",
     "sentry.api.endpoints.event_attachment_details",
@@ -1153,7 +1147,6 @@ module = [
     "sentry.web.frontend.shared_group_details",
     "sentry.web.frontend.twofactor",
     "sentry.web.frontend.unsubscribe_notifications",
-    "sentry.wsgi",
     "sentry_plugins.asana.plugin",
     "sentry_plugins.base",
     "sentry_plugins.bitbucket.client",

+ 1 - 1
src/sentry/api/endpoints/admin_project_configs.py

@@ -31,7 +31,7 @@ class AdminRelayProjectConfigsEndpoint(Endpoint):
 
         configs = {}
         for key in project_keys:
-            cached_config = projectconfig_cache.get(key)
+            cached_config = projectconfig_cache.backend.get(key)
             if cached_config is not None:
                 configs[key] = cached_config
             else:

+ 2 - 1
src/sentry/api/endpoints/api_applications.py

@@ -1,8 +1,9 @@
+from rest_framework.authentication import SessionAuthentication
 from rest_framework.permissions import IsAuthenticated
 from rest_framework.request import Request
 from rest_framework.response import Response
 
-from sentry.api.base import Endpoint, SessionAuthentication, control_silo_endpoint
+from sentry.api.base import Endpoint, control_silo_endpoint
 from sentry.api.paginator import OffsetPaginator
 from sentry.api.serializers import serialize
 from sentry.models import ApiApplication, ApiApplicationStatus

+ 2 - 1
src/sentry/api/endpoints/api_authorizations.py

@@ -1,9 +1,10 @@
 from django.db import router, transaction
+from rest_framework.authentication import SessionAuthentication
 from rest_framework.permissions import IsAuthenticated
 from rest_framework.request import Request
 from rest_framework.response import Response
 
-from sentry.api.base import Endpoint, SessionAuthentication, control_silo_endpoint
+from sentry.api.base import Endpoint, control_silo_endpoint
 from sentry.api.paginator import OffsetPaginator
 from sentry.api.serializers import serialize
 from sentry.models import ApiApplicationStatus, ApiAuthorization, ApiToken

+ 1 - 1
src/sentry/api/endpoints/auth_index.py

@@ -47,7 +47,7 @@ class AuthIndexEndpoint(Endpoint):
     and simple HTTP authentication.
     """
 
-    authentication_classes = [QuietBasicAuthentication, SessionAuthentication]
+    authentication_classes = (QuietBasicAuthentication, SessionAuthentication)
 
     permission_classes = ()
 

+ 4 - 4
src/sentry/api/endpoints/broadcast_index.py

@@ -60,11 +60,11 @@ class BroadcastIndexEndpoint(OrganizationEndpoint):
             tokens = tokenize_query(query)
             for key, value in tokens.items():
                 if key == "query":
-                    value = " ".join(value)
+                    value_str = " ".join(value)
                     queryset = queryset.filter(
-                        Q(title__icontains=value)
-                        | Q(message__icontains=value)
-                        | Q(link__icontains=value)
+                        Q(title__icontains=value_str)
+                        | Q(message__icontains=value_str)
+                        | Q(link__icontains=value_str)
                     )
                 elif key == "id":
                     queryset = queryset.filter(id__in=value)

+ 1 - 1
src/sentry/api/endpoints/debug_files.py

@@ -85,7 +85,7 @@ class DebugFilesEndpoint(ProjectEndpoint):
     permission_classes = (ProjectReleasePermission,)
 
     def download(self, debug_file_id, project):
-        rate_limited = ratelimits.is_limited(
+        rate_limited = ratelimits.backend.is_limited(
             project=project,
             key=f"rl:DSymFilesEndpoint:download:{debug_file_id}:{project.id}",
             limit=10,

+ 1 - 1
src/sentry/wsgi.py

@@ -34,7 +34,7 @@ class FileWrapperWSGIHandler(WSGIHandler):
         response = super().__call__(environ, start_response)
         if hasattr(response, "streaming") and response.streaming:
             try:
-                response = environ["wsgi.file_wrapper"](response.streaming_content)
+                response = environ["wsgi.file_wrapper"](response.streaming_content)  # type: ignore[attr-defined]
             except KeyError:
                 # In our case, we're shipping with uwsgi, so it's safer to assume
                 # that wsgi.file_wrapper does exist. It'd be exceptional otherwise.