diff --git a/pyproject.toml b/pyproject.toml index 57757723ee1f..52283c7fbfb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1286,7 +1286,6 @@ module = [ "sentry.sentry_apps.api.parsers.*", "sentry.sentry_apps.api.serializers.*", "sentry.sentry_apps.components", - "sentry.sentry_apps.external_requests.*", "sentry.sentry_apps.installations", "sentry.sentry_apps.logic", "sentry.sentry_apps.metrics", diff --git a/src/sentry/sentry_apps/external_requests/alert_rule_action_requester.py b/src/sentry/sentry_apps/external_requests/alert_rule_action_requester.py index e43cbc9de5ec..768802e2f38c 100644 --- a/src/sentry/sentry_apps/external_requests/alert_rule_action_requester.py +++ b/src/sentry/sentry_apps/external_requests/alert_rule_action_requester.py @@ -20,8 +20,9 @@ SentryAppInteractionEvent, SentryAppInteractionType, ) +from sentry.sentry_apps.models.sentry_app import SentryApp from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation -from sentry.sentry_apps.services.app.model import RpcSentryAppInstallation +from sentry.sentry_apps.services.app.model import RpcSentryApp, RpcSentryAppInstallation from sentry.sentry_apps.utils.errors import SentryAppErrorType, SentryAppIntegratorError from sentry.utils import json @@ -160,7 +161,7 @@ def _get_response_message(self, response: Response | None, default_message: str) return f"{self.sentry_app.name}: {message}" @cached_property - def body(self): + def body(self) -> str: return json.dumps( { "fields": self.fields, @@ -169,5 +170,5 @@ def body(self): ) @cached_property - def sentry_app(self): + def sentry_app(self) -> SentryApp | RpcSentryApp: return self.install.sentry_app diff --git a/src/sentry/sentry_apps/external_requests/issue_link_requester.py b/src/sentry/sentry_apps/external_requests/issue_link_requester.py index cd8d2d8f4813..1ac66c72a4c0 100644 --- a/src/sentry/sentry_apps/external_requests/issue_link_requester.py +++ b/src/sentry/sentry_apps/external_requests/issue_link_requester.py @@ -23,7 +23,9 @@ SentryAppInteractionEvent, SentryAppInteractionType, ) +from sentry.sentry_apps.models.sentry_app import SentryApp from sentry.sentry_apps.services.app import RpcSentryAppInstallation +from sentry.sentry_apps.services.app.model import RpcSentryApp from sentry.sentry_apps.utils.errors import SentryAppIntegratorError from sentry.users.models.user import User from sentry.users.services.user import RpcUser @@ -185,7 +187,7 @@ def _build_headers(self) -> dict[str, str]: } @cached_property - def body(self): + def body(self) -> str: body: dict[str, Any] = { "fields": {}, "issueId": self.group.id, @@ -199,5 +201,5 @@ def body(self): return json.dumps(body) @cached_property - def sentry_app(self): + def sentry_app(self) -> SentryApp | RpcSentryApp: return self.install.sentry_app diff --git a/src/sentry/sentry_apps/external_requests/utils.py b/src/sentry/sentry_apps/external_requests/utils.py index 5fd485490fc8..1bb883e99ac1 100644 --- a/src/sentry/sentry_apps/external_requests/utils.py +++ b/src/sentry/sentry_apps/external_requests/utils.py @@ -1,7 +1,7 @@ import logging import re from collections.abc import Mapping -from typing import Any +from typing import Any, Literal from urllib.parse import urlparse from jsonschema import Draft7Validator @@ -94,14 +94,8 @@ def integrator_error_message(response: Response | None, fallback: str) -> str: SCHEMA_LIST = {"select": SELECT_OPTIONS_SCHEMA, "issue_link": ISSUE_LINKER_SCHEMA} -def validate(instance, schema_type): - schema = SCHEMA_LIST[schema_type] - v = Draft7Validator(schema) - - if not v.is_valid(instance): - return False - - return True +def validate(instance: object, schema_type: Literal["select", "issue_link"]) -> bool: + return Draft7Validator(SCHEMA_LIST[schema_type]).is_valid(instance) def send_and_save_sentry_app_request(