Browse Source

ref(types): fix type on permission_classes in base endpoint (#50598)

- fixes the base type on the `Endpoint` class, which allows at least the
replay details to be type checked successfully.

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Josh Ferge 1 year ago
parent
commit
3c233d1ff3
2 changed files with 3 additions and 59 deletions
  1. 0 57
      pyproject.toml
  2. 3 2
      src/sentry/api/base.py

+ 0 - 57
pyproject.toml

@@ -188,20 +188,16 @@ module = [
     "sentry.api.endpoints.api_applications",
     "sentry.api.endpoints.api_authorizations",
     "sentry.api.endpoints.api_tokens",
-    "sentry.api.endpoints.artifact_bundles",
     "sentry.api.endpoints.artifact_lookup",
-    "sentry.api.endpoints.assistant",
     "sentry.api.endpoints.auth_config",
     "sentry.api.endpoints.auth_index",
     "sentry.api.endpoints.auth_login",
-    "sentry.api.endpoints.authenticator_index",
     "sentry.api.endpoints.avatar.doc_integration",
     "sentry.api.endpoints.avatar.organization",
     "sentry.api.endpoints.avatar.project",
     "sentry.api.endpoints.avatar.sentry_app",
     "sentry.api.endpoints.avatar.team",
     "sentry.api.endpoints.avatar.user",
-    "sentry.api.endpoints.broadcast_details",
     "sentry.api.endpoints.broadcast_index",
     "sentry.api.endpoints.builtin_symbol_sources",
     "sentry.api.endpoints.catchall",
@@ -261,31 +257,18 @@ module = [
     "sentry.api.endpoints.integrations.sentry_apps.stats.details",
     "sentry.api.endpoints.integrations.sentry_apps.stats.index",
     "sentry.api.endpoints.internal.beacon",
-    "sentry.api.endpoints.internal.environment",
     "sentry.api.endpoints.internal.integration_proxy",
     "sentry.api.endpoints.internal.mail",
-    "sentry.api.endpoints.internal.packages",
-    "sentry.api.endpoints.internal.queue_tasks",
-    "sentry.api.endpoints.internal.quotas",
     "sentry.api.endpoints.internal.stats",
-    "sentry.api.endpoints.internal.warnings",
     "sentry.api.endpoints.issue_occurrence",
     "sentry.api.endpoints.notifications.notification_actions_available",
     "sentry.api.endpoints.notifications.notification_actions_details",
-    "sentry.api.endpoints.notifications.notification_actions_index",
     "sentry.api.endpoints.organization_access_request_details",
-    "sentry.api.endpoints.organization_api_key_details",
-    "sentry.api.endpoints.organization_api_key_index",
-    "sentry.api.endpoints.organization_auditlogs",
-    "sentry.api.endpoints.organization_auth_provider_details",
     "sentry.api.endpoints.organization_auth_provider_send_reminders",
-    "sentry.api.endpoints.organization_auth_providers",
     "sentry.api.endpoints.organization_code_mapping_codeowners",
     "sentry.api.endpoints.organization_code_mapping_details",
     "sentry.api.endpoints.organization_code_mappings",
-    "sentry.api.endpoints.organization_codeowners_associations",
     "sentry.api.endpoints.organization_dashboard_details",
-    "sentry.api.endpoints.organization_dashboard_widget_details",
     "sentry.api.endpoints.organization_dashboards",
     "sentry.api.endpoints.organization_derive_code_mappings",
     "sentry.api.endpoints.organization_details",
@@ -309,7 +292,6 @@ module = [
     "sentry.api.endpoints.organization_index",
     "sentry.api.endpoints.organization_integration_repos",
     "sentry.api.endpoints.organization_issues_count",
-    "sentry.api.endpoints.organization_issues_resolved_in_release",
     "sentry.api.endpoints.organization_member",
     "sentry.api.endpoints.organization_member.details",
     "sentry.api.endpoints.organization_member.index",
@@ -321,12 +303,8 @@ module = [
     "sentry.api.endpoints.organization_metrics",
     "sentry.api.endpoints.organization_metrics_meta",
     "sentry.api.endpoints.organization_onboarding_continuation_email",
-    "sentry.api.endpoints.organization_onboarding_tasks",
-    "sentry.api.endpoints.organization_pinned_searches",
     "sentry.api.endpoints.organization_projects",
     "sentry.api.endpoints.organization_projects_experiment",
-    "sentry.api.endpoints.organization_recent_searches",
-    "sentry.api.endpoints.organization_relay_usage",
     "sentry.api.endpoints.organization_release_details",
     "sentry.api.endpoints.organization_releases",
     "sentry.api.endpoints.organization_repositories",
@@ -342,14 +320,8 @@ module = [
     "sentry.api.endpoints.organization_tagkey_values",
     "sentry.api.endpoints.organization_tags",
     "sentry.api.endpoints.organization_teams",
-    "sentry.api.endpoints.organization_user_details",
-    "sentry.api.endpoints.organization_user_reports",
     "sentry.api.endpoints.project_app_store_connect_credentials",
     "sentry.api.endpoints.project_artifact_bundle_file_details",
-    "sentry.api.endpoints.project_artifact_bundle_files",
-    "sentry.api.endpoints.project_commits",
-    "sentry.api.endpoints.project_create_sample",
-    "sentry.api.endpoints.project_create_sample_transaction",
     "sentry.api.endpoints.project_details",
     "sentry.api.endpoints.project_dynamic_sampling",
     "sentry.api.endpoints.project_event_details",
@@ -358,24 +330,15 @@ module = [
     "sentry.api.endpoints.project_group_stats",
     "sentry.api.endpoints.project_grouping_configs",
     "sentry.api.endpoints.project_index",
-    "sentry.api.endpoints.project_issues_resolved_in_release",
     "sentry.api.endpoints.project_key_details",
     "sentry.api.endpoints.project_key_stats",
     "sentry.api.endpoints.project_keys",
     "sentry.api.endpoints.project_ownership",
-    "sentry.api.endpoints.project_performance_issue_settings",
-    "sentry.api.endpoints.project_release_commits",
     "sentry.api.endpoints.project_release_details",
-    "sentry.api.endpoints.project_release_file_details",
     "sentry.api.endpoints.project_release_files",
-    "sentry.api.endpoints.project_release_repositories",
-    "sentry.api.endpoints.project_release_setup",
     "sentry.api.endpoints.project_release_stats",
     "sentry.api.endpoints.project_releases",
-    "sentry.api.endpoints.project_releases_token",
     "sentry.api.endpoints.project_repo_path_parsing",
-    "sentry.api.endpoints.project_reprocessing",
-    "sentry.api.endpoints.project_rule_actions",
     "sentry.api.endpoints.project_rule_details",
     "sentry.api.endpoints.project_rule_preview",
     "sentry.api.endpoints.project_rule_task_details",
@@ -389,17 +352,12 @@ module = [
     "sentry.api.endpoints.project_tagkey_details",
     "sentry.api.endpoints.project_tagkey_values",
     "sentry.api.endpoints.project_tags",
-    "sentry.api.endpoints.project_team_details",
     "sentry.api.endpoints.project_transaction_names",
-    "sentry.api.endpoints.project_transaction_threshold",
-    "sentry.api.endpoints.project_transaction_threshold_override",
     "sentry.api.endpoints.project_transfer",
     "sentry.api.endpoints.project_user_reports",
     "sentry.api.endpoints.project_user_stats",
     "sentry.api.endpoints.prompts_activity",
-    "sentry.api.endpoints.relay.details",
     "sentry.api.endpoints.relay.health_check",
-    "sentry.api.endpoints.relay.index",
     "sentry.api.endpoints.relay.project_configs",
     "sentry.api.endpoints.relay.project_ids",
     "sentry.api.endpoints.relay.public_keys",
@@ -410,11 +368,9 @@ module = [
     "sentry.api.endpoints.setup_wizard",
     "sentry.api.endpoints.shared_group_details",
     "sentry.api.endpoints.source_map_debug",
-    "sentry.api.endpoints.system_health",
     "sentry.api.endpoints.system_options",
     "sentry.api.endpoints.team_details",
     "sentry.api.endpoints.team_notification_settings_details",
-    "sentry.api.endpoints.team_projects",
     "sentry.api.endpoints.team_release_count",
     "sentry.api.endpoints.team_stats",
     "sentry.api.endpoints.team_time_to_resolution",
@@ -436,8 +392,6 @@ module = [
     "sentry.api.endpoints.user_roles",
     "sentry.api.endpoints.user_social_identity_details",
     "sentry.api.endpoints.user_subscriptions",
-    "sentry.api.endpoints.userroles_details",
-    "sentry.api.endpoints.userroles_index",
     "sentry.api.event_search",
     "sentry.api.exceptions",
     "sentry.api.fields.actor",
@@ -551,7 +505,6 @@ module = [
     "sentry.conf.urls",
     "sentry.coreapi",
     "sentry.data_export.endpoints.data_export",
-    "sentry.data_export.endpoints.data_export_details",
     "sentry.data_export.models",
     "sentry.data_export.processors.issues_by_tag",
     "sentry.data_export.tasks",
@@ -583,7 +536,6 @@ module = [
     "sentry.discover.endpoints.discover_homepage_query",
     "sentry.discover.endpoints.discover_key_transactions",
     "sentry.discover.endpoints.discover_saved_queries",
-    "sentry.discover.endpoints.discover_saved_query_detail",
     "sentry.discover.endpoints.serializers",
     "sentry.discover.models",
     "sentry.discover.tasks",
@@ -637,14 +589,9 @@ module = [
     "sentry.incidents.endpoints.organization_alert_rule_available_action_index",
     "sentry.incidents.endpoints.organization_alert_rule_details",
     "sentry.incidents.endpoints.organization_alert_rule_index",
-    "sentry.incidents.endpoints.organization_incident_activity_index",
     "sentry.incidents.endpoints.organization_incident_comment_details",
     "sentry.incidents.endpoints.organization_incident_comment_index",
-    "sentry.incidents.endpoints.organization_incident_details",
     "sentry.incidents.endpoints.organization_incident_index",
-    "sentry.incidents.endpoints.organization_incident_seen",
-    "sentry.incidents.endpoints.organization_incident_subscription_index",
-    "sentry.incidents.endpoints.project_alert_rule_index",
     "sentry.incidents.endpoints.project_alert_rule_task_details",
     "sentry.incidents.events",
     "sentry.incidents.logic",
@@ -1080,7 +1027,6 @@ module = [
     "sentry.replays.endpoints.organization_replay_count",
     "sentry.replays.endpoints.organization_replay_index",
     "sentry.replays.endpoints.project_replay_clicks_index",
-    "sentry.replays.endpoints.project_replay_details",
     "sentry.replays.endpoints.project_replay_recording_segment_details",
     "sentry.replays.endpoints.project_replay_recording_segment_index",
     "sentry.replays.lib.consumer",
@@ -1127,7 +1073,6 @@ module = [
     "sentry.runner.initializer",
     "sentry.runner.settings",
     "sentry.scim.endpoints.members",
-    "sentry.scim.endpoints.schemas",
     "sentry.scim.endpoints.teams",
     "sentry.scim.endpoints.utils",
     "sentry.sdk_updates",
@@ -1660,7 +1605,6 @@ module = [
     "tests.sentry.api.test_authentication",
     "tests.sentry.api.test_base",
     "tests.sentry.api.test_event_search",
-    "tests.sentry.api.test_handlers",
     "tests.sentry.api.test_invite_helper",
     "tests.sentry.api.test_issue_search",
     "tests.sentry.api.test_paginator",
@@ -1936,7 +1880,6 @@ module = [
     "tests.sentry.middleware.integrations.parsers.test_base",
     "tests.sentry.middleware.integrations.parsers.test_github",
     "tests.sentry.middleware.integrations.parsers.test_slack",
-    "tests.sentry.middleware.test_access_log_middleware",
     "tests.sentry.middleware.test_auth",
     "tests.sentry.middleware.test_customer_domain",
     "tests.sentry.middleware.test_proxy",

+ 3 - 2
src/sentry/api/base.py

@@ -4,7 +4,7 @@ import functools
 import logging
 import time
 from datetime import datetime, timedelta
-from typing import Any, Callable, Iterable, List, Mapping, Optional, Type
+from typing import Any, Callable, Iterable, List, Mapping, Optional, Tuple, Type
 
 import sentry_sdk
 from django.conf import settings
@@ -21,6 +21,7 @@ from rest_framework.views import APIView
 from sentry_sdk import Scope
 
 from sentry import analytics, options, tsdb
+from sentry.api import permissions
 from sentry.apidocs.hooks import HTTP_METHODS_SET
 from sentry.auth import access
 from sentry.models import Environment
@@ -125,7 +126,7 @@ def allow_cors_options(func):
 class Endpoint(APIView):
     # Note: the available renderer and parser classes can be found in conf/server.py.
     authentication_classes = DEFAULT_AUTHENTICATION
-    permission_classes = (NoPermission,)
+    permission_classes: Tuple[Type[permissions.BasePermission]] = (NoPermission,)
 
     cursor_name = "cursor"