Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/sentry/plugins/bases/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
from sentry.integrations.types import ExternalProviders
from sentry.notifications.services.service import notifications_service
from sentry.notifications.types import NotificationSettingEnum
from sentry.plugins.base import Notification, Plugin
from sentry.plugins.base import Plugin
from sentry.plugins.base.configuration import react_plugin_config
from sentry.plugins.base.structs import Notification
from sentry.shared_integrations.exceptions import ApiError
from sentry.types.actor import Actor, ActorType

Expand Down Expand Up @@ -51,7 +52,7 @@ def configure(self, project, request):
def get_plugin_type(self):
return "notification"

def notify(self, notification, raise_exception=False):
def notify(self, notification: Notification, raise_exception: bool = False) -> None:
"""
This calls the notify_users method of the plugin.
Normally this method eats the error and logs it but if we
Expand All @@ -60,7 +61,7 @@ def notify(self, notification, raise_exception=False):
"""
event = notification.event
try:
return self.notify_users(
self.notify_users(
event.group, event, triggering_rules=[r.label for r in notification.rules]
)
except (
Expand All @@ -82,7 +83,6 @@ def notify(self, notification, raise_exception=False):
)
if raise_exception:
raise
return False

def rule_notify(self, event, futures):
rules = []
Expand Down Expand Up @@ -180,16 +180,16 @@ def should_notify(self, group, event):

return True

def test_configuration(self, project):
def test_configuration(self, project) -> None:
from sentry.utils.samples import create_sample_event

event = create_sample_event(project, platform="python")
notification = Notification(event=event)
return self.notify(notification, raise_exception=True)
self.notify(notification, raise_exception=True)

def test_configuration_and_get_test_results(self, project):
try:
test_results = self.test_configuration(project)
self.test_configuration(project)
except Exception as exc:
if isinstance(exc, HTTPError) and hasattr(exc.response, "text"):
test_results = f"{exc}\n{exc.response.text[:256]}"
Expand All @@ -202,7 +202,7 @@ def test_configuration_and_get_test_results(self, project):
test_results = (
"There was an internal error with the Plugin, %s" % str(exc)[:256]
)
if not test_results:
else:
test_results = "No errors returned"
return test_results

Expand Down
3 changes: 2 additions & 1 deletion src/sentry_plugins/pushover/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from sentry.exceptions import PluginError
from sentry.integrations.base import FeatureDescription, IntegrationFeatures
from sentry.plugins.base.structs import Notification
from sentry.plugins.bases.notify import NotifyPlugin
from sentry_plugins.base import CorePluginMixin
from sentry_plugins.utils import get_secret_field_config
Expand Down Expand Up @@ -106,7 +107,7 @@ def error_message_from_json(self, data):
return " ".join(errors)
return "unknown error"

def notify(self, notification, **kwargs):
def notify(self, notification: Notification, raise_exception: bool = False) -> None:
event = notification.event
group = event.group
project = group.project
Expand Down
2 changes: 1 addition & 1 deletion src/sentry_plugins/slack/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sentry import tagstore
from sentry.integrations.base import FeatureDescription, IntegrationFeatures
from sentry.integrations.slack.message_builder import LEVEL_TO_COLOR
from sentry.plugins.base import Notification
from sentry.plugins.base.structs import Notification
from sentry.plugins.bases import notify
from sentry.shared_integrations.exceptions import ApiError
from sentry.utils import json
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry/plugins/bases/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_notify_failure(self):
notification = Notification(event)

with mock.patch.object(DummyNotificationPlugin, "notify_users", side_effect=err):
assert n.notify(notification) is False
n.notify(notification) # does not raise!

def test_test_configuration_and_get_test_results(self):
errors = (
Expand Down