Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: remove some dead code from plugins #83581

Merged
merged 25 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1308753
ref: remove dead get_users_for_project
asottile-sentry Jan 16, 2025
73010b7
ref: remove unused get_form_initial
asottile-sentry Jan 16, 2025
e0b77a8
ref: remove unused get_resource_links
asottile-sentry Jan 16, 2025
ecea094
ref: remove dead get_available_auths
asottile-sentry Jan 16, 2025
01d6465
ref: remove unreferenced HTTP_TIMEOUT
asottile-sentry Jan 16, 2025
6c06896
ref: remove unused RedmineOptionsForm
asottile-sentry Jan 16, 2025
36ae49d
ref: remove unused get_event_props
asottile-sentry Jan 16, 2025
990f7d2
ref: remove unused get_install_url
asottile-sentry Jan 16, 2025
152e59b
ref: remove unused PluginStatus / PluginStatusMixin
asottile-sentry Jan 16, 2025
e06192d
ref: remove unused get_auth_url
asottile-sentry Jan 16, 2025
f4a5f06
ref: remove unused start_release
asottile-sentry Jan 16, 2025
efba2bd
ref: remove VALIDATOR_ERRORS
asottile-sentry Jan 16, 2025
8cf644c
ref: remove compatibilty for NotifyPlugin name
asottile-sentry Jan 16, 2025
f3459d3
ref: remove unused for_site
asottile-sentry Jan 16, 2025
897dbcd
ref: remove unused plugin conf methods
asottile-sentry Jan 16, 2025
ec4292a
ref: remove unused before_events
asottile-sentry Jan 16, 2025
5282580
ref: remove unused panels
asottile-sentry Jan 16, 2025
c80bcff
ref: remove missing_perm_response
asottile-sentry Jan 16, 2025
ef0b82e
ref: remove unused get_notification_forms
asottile-sentry Jan 16, 2025
51228a1
ref: remove unused get_feature_hooks
asottile-sentry Jan 16, 2025
1127f43
ref: remove unused get_unlink_issue_title
asottile-sentry Jan 16, 2025
ae7b15a
ref: remove unused get_issue_doc_html
asottile-sentry Jan 16, 2025
9a27473
ref: remove unused BaseNotificationUserOptionsForm
asottile-sentry Jan 16, 2025
6abb058
ref: remove unused get_notification_doc_html
asottile-sentry Jan 16, 2025
f4ba954
ref: remove unused add_notification_referrer_param
asottile-sentry Jan 16, 2025
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
1 change: 0 additions & 1 deletion src/sentry/api/serializers/models/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def serialize(self, obj, attrs, user, **kwargs):
"hasConfiguration": obj.has_project_conf(),
"metadata": obj.get_metadata(),
"contexts": contexts,
"status": obj.get_status(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there some associated frontend type change or anything for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to find one but I don't think our frontend actually loads or uses this at all

"doc": doc,
"firstPartyAlternative": getattr(obj, "alternative", None),
"deprecationDate": (
Expand Down
5 changes: 0 additions & 5 deletions src/sentry/integrations/jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ def get_versions(self, project):
def get_priorities(self):
return self.get_cached(self.PRIORITIES_URL)

def get_users_for_project(self, project):
# Jira Server wants a project key, while cloud is indifferent.
project_key = self.get_project_key_for_id(project)
return self.get_cached(self.USERS_URL, params={"project": project_key})

def search_users_for_project(self, project, username):
# Jira Server wants a project key, while cloud is indifferent.
project_key = self.get_project_key_for_id(project)
Expand Down
5 changes: 0 additions & 5 deletions src/sentry/integrations/jira_server/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,6 @@ def get_priorities(self):
"""
return self.get_cached(self.PRIORITIES_URL)

def get_users_for_project(self, project):
# Jira Server wants a project key, while cloud is indifferent.
project_key = self.get_project_key_for_id(project)
return self.get_cached(self.USERS_URL, params={"project": project_key})

def search_users_for_project(self, project, username):
# Jira Server wants a project key, while cloud is indifferent.
project_key = self.get_project_key_for_id(project)
Expand Down
6 changes: 0 additions & 6 deletions src/sentry/plugins/base/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ def for_project(self, project, version=1):
continue
yield plugin

def for_site(self, version=1):
for plugin in self.all(version=version):
if not plugin.has_site_conf():
continue
yield plugin

def get(self, slug):
for plugin in self.all(version=None):
if plugin.slug == slug:
Expand Down
106 changes: 1 addition & 105 deletions src/sentry/plugins/base/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from sentry.plugins.base.response import DeferredResponse
from sentry.plugins.base.view import PluggableViewMixin
from sentry.plugins.config import PluginConfigMixin
from sentry.plugins.status import PluginStatusMixin
from sentry.projects.services.project import RpcProject

if TYPE_CHECKING:
Expand All @@ -37,7 +36,7 @@ def __new__(cls, name, bases, attrs):
return new_cls


class IPlugin(local, PluggableViewMixin, PluginConfigMixin, PluginStatusMixin):
class IPlugin(local, PluggableViewMixin, PluginConfigMixin):
"""
Plugin interface. Should not be inherited from directly.

Expand Down Expand Up @@ -70,10 +69,6 @@ class IPlugin(local, PluggableViewMixin, PluginConfigMixin, PluginStatusMixin):
conf_title: str | _StrPromise | None = None

project_conf_form: Any = None
project_conf_template = "sentry/plugins/project_configuration.html"

site_conf_form: Any = None
site_conf_template = "sentry/plugins/site_configuration.html"

# Global enabled state
enabled = True
Expand Down Expand Up @@ -184,44 +179,15 @@ def get_conf_key(self):
return self.get_conf_title().lower().replace(" ", "_")
return self.conf_key

def get_conf_form(self, project=None):
"""
Returns the Form required to configure the plugin.

>>> plugin.get_conf_form(project)
"""
if project is not None:
return self.project_conf_form
return self.site_conf_form

def get_conf_template(self, project=None):
"""
Returns the template required to render the configuration page.

>>> plugin.get_conf_template(project)
"""
if project is not None:
return self.project_conf_template
return self.site_conf_template

def get_conf_title(self):
"""
Returns a string representing the title to be shown on the configuration page.
"""
return self.conf_title or self.get_title()

def has_site_conf(self):
return self.site_conf_form is not None

def has_project_conf(self):
return self.project_conf_form is not None

def has_plugin_conf(self):
"""
Checks if the plugin should be returned in the ProjectPluginsEndpoint
"""
return self.has_project_conf()

def can_enable_for_projects(self):
"""
Returns a boolean describing whether this plugin can be enabled for
Expand Down Expand Up @@ -249,9 +215,6 @@ def can_configure_for_project(self, project):

return True

def get_form_initial(self, project=None):
return {}

# The following methods are specific to web requests

def get_title(self) -> str | _StrPromise:
Expand All @@ -273,19 +236,6 @@ def get_description(self) -> str | None:
"""
return self.description

def get_resource_links(self) -> Sequence[tuple[str, str]]:
"""
Returns a list of tuples pointing to various resources for this plugin.

>>> def get_resource_links(self):
>>> return [
>>> ('Documentation', 'https://docs.sentry.io'),
>>> ('Report Issue', 'https://github.com/getsentry/sentry/issues'),
>>> ('View Source', 'https://github.com/getsentry/sentry'),
>>> ]
"""
return self.resource_links

def get_view_response(self, request, group):
self.selected = request.path == self.get_url(group)

Expand Down Expand Up @@ -329,25 +279,6 @@ def view(self, request, group, **kwargs):
>>> return self.render('myplugin/about.html')
"""

def before_events(self, request, group_list, **kwargs):
"""
Allows preprocessing of groups in the list view.

This is generally useful if you need to cache lookups
for something like ``tags`` which would otherwise do
multiple queries.

If you use this **at all** you should ensure it's already
reset on each execution.

As an example, here's how we might get a reference to ticket ids we were
storing per event, in an efficient O(1) manner.

>>> def before_events(self, request, event_list, **kwargs):
>>> prefix = self.get_conf_key()
>>> GroupMeta.objects.get_value_bulk(event_list, '%s:tid' % prefix)
"""

def tags(self, request, group, tag_list, **kwargs):
"""
Modifies the tag list for a grouped message.
Expand Down Expand Up @@ -379,22 +310,6 @@ def actions(self, request, group, action_list, **kwargs):
"""
return action_list

def panels(self, request, group, panel_list, **kwargs):
"""
Modifies the panel list for a grouped message.

A panel is a tuple containing two elements:

('Panel Label', '/uri/to/panel/')

This must return ``panel_list``.

>>> def panels(self, request, group, action_list, **kwargs):
>>> panel_list.append((self.get_title(), self.get_url(group)))
>>> return panel_list
"""
return panel_list

def widget(self, request, group, **kwargs):
"""
Renders as a widget in the group details sidebar.
Expand All @@ -405,14 +320,6 @@ def widget(self, request, group, **kwargs):

# Server side signals which do not have request context

def has_perm(self, user, perm, *objects, **kwargs):
# DEPRECATED: No longer used.
pass

def missing_perm_response(self, request, perm, *args, **objects):
# DEPRECATED: No longer used.
pass

def is_regression(self, group, event, **kwargs):
"""
Called on new events when the group's status is resolved.
Expand Down Expand Up @@ -452,17 +359,6 @@ def get_tags(self, event, **kwargs):
>>> return [('tag-name', 'tag-value')]
"""

def get_notification_forms(self, **kwargs):
"""
Provides additional UserOption forms for the Notification Settings page.

Must return an iterable.

>>> def get_notification_forms(self, **kwargs):
>>> return [MySettingsForm]
"""
return []

def is_testable(self, **kwargs):
"""
Returns True if this plugin is able to be tested.
Expand Down
63 changes: 1 addition & 62 deletions src/sentry/plugins/base/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from sentry.plugins.base.response import DeferredResponse
from sentry.plugins.config import PluginConfigMixin
from sentry.plugins.interfaces.releasehook import ReleaseHook
from sentry.plugins.status import PluginStatusMixin

if TYPE_CHECKING:
from django.utils.functional import _StrPromise
Expand All @@ -35,7 +34,7 @@ def __new__(cls, name, bases, attrs):
return new_cls


class IPlugin2(local, PluginConfigMixin, PluginStatusMixin):
class IPlugin2(local, PluginConfigMixin):
"""
Plugin interface. Should not be inherited from directly.

Expand Down Expand Up @@ -68,7 +67,6 @@ class IPlugin2(local, PluginConfigMixin, PluginStatusMixin):
conf_title: str | _StrPromise | None = None

project_conf_form: Any = None
project_conf_template = "sentry/plugins/project_configuration.html"

# Global enabled state
enabled = True
Expand Down Expand Up @@ -175,44 +173,15 @@ def get_conf_key(self):
self.conf_key = self.get_conf_title().lower().replace(" ", "_")
return self.conf_key

def get_conf_form(self, project=None):
"""
Returns the Form required to configure the plugin.

>>> plugin.get_conf_form(project)
"""
if project is not None:
return self.project_conf_form
return self.site_conf_form

def get_conf_template(self, project=None):
"""
Returns the template required to render the configuration page.

>>> plugin.get_conf_template(project)
"""
if project is not None:
return self.project_conf_template
return self.site_conf_template

def get_conf_title(self):
"""
Returns a string representing the title to be shown on the configuration page.
"""
return self.conf_title or self.get_title()

def get_form_initial(self, project=None):
return {}

def has_project_conf(self):
return self.project_conf_form is not None

def has_plugin_conf(self):
"""
Checks if the plugin should be returned in the ProjectPluginsEndpoint
"""
return self.has_project_conf()

def can_configure_for_project(self, project):
"""
Checks if the plugin can be configured for a specific project.
Expand Down Expand Up @@ -273,19 +242,6 @@ def get_description(self):
"""
return self.description

def get_resource_links(self):
"""
Returns a list of tuples pointing to various resources for this plugin.

>>> def get_resource_links(self):
>>> return [
>>> ('Documentation', 'https://docs.sentry.io'),
>>> ('Report Issue', 'https://github.com/getsentry/sentry/issues'),
>>> ('View Source', 'https://github.com/getsentry/sentry'),
>>> ]
"""
return self.resource_links

def get_rules(self, **kwargs):
"""
Return a list of Rule classes to add to the registry.
Expand Down Expand Up @@ -373,23 +329,6 @@ def get_stacktrace_processors(self, data, stacktrace_infos,
return [CocoaProcessor(data, stacktrace_infos)]
"""

def get_feature_hooks(self, **kwargs):
"""
Return a list of callables to check for feature status.

>>> from sentry.features import FeatureHandler
>>>
>>> class NoRegistration(FeatureHandler):
>>> features = set(['auth:register'])
>>>
>>> def has(self, feature, actor):
>>> return False

>>> def get_feature_hooks(self, **kwargs):
>>> return [NoRegistration()]
"""
return []

def get_release_hook(self) -> type[ReleaseHook] | None:
"""
Return an implementation of ``ReleaseHook``.
Expand Down
19 changes: 0 additions & 19 deletions src/sentry/plugins/bases/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ def get_new_issue_title(self, **kwargs):
"""
return "Create %s Issue" % self.get_title()

def get_unlink_issue_title(self, **kwargs):
"""
Return a string for the "Unlink plugin issue" action label.
"""
return "Unlink %s Issue" % self.get_title()

def get_new_issue_form(self, request: Request, group, event, **kwargs):
"""
Return a Form for the "Create new issue" page.
Expand All @@ -119,12 +113,6 @@ def get_issue_url(self, group, issue_id: str) -> str:
"""
raise NotImplementedError

def get_issue_title_by_id(self, request: Request, group, issue_id):
"""
Given an issue_id return the issue's title.
"""
raise NotImplementedError

def get_issue_label(self, group, issue_id) -> str:
"""
Given an issue_id (string) return a string representing the issue.
Expand Down Expand Up @@ -157,10 +145,6 @@ def has_auth_configured(self, **kwargs):

return self.auth_provider in get_auth_providers()

def handle_unlink_issue(self, request: Request, group, **kwargs):
GroupMeta.objects.unset_value(group, "%s:tid" % self.get_conf_key())
return self.redirect(group.get_absolute_url())

def view(self, request: Request, group, **kwargs):
has_auth_configured = self.has_auth_configured()
if not (has_auth_configured and self.is_configured(project=group.project)):
Expand Down Expand Up @@ -269,8 +253,5 @@ def tags(self, request: Request, group, tag_list, **kwargs):

return tag_list

def get_issue_doc_html(self, **kwargs):
return ""


IssuePlugin = IssueTrackingPlugin
Loading
Loading