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: unify the signature of Interface.to_string #74798

Merged
merged 1 commit into from
Jul 24, 2024
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
2 changes: 1 addition & 1 deletion src/sentry/interfaces/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def get_score(self) -> int:
def iter_tags(self):
return iter(())

def to_string(self, event, is_public=False, **kwargs):
def to_string(self, event) -> str:
return ""

def to_email_html(self, event, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/interfaces/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def get_api_meta(self, meta, is_public=False, platform=None):

return {"values": result}

def to_string(self, event, is_public=False, **kwargs):
def to_string(self, event) -> str:
if not self.values:
return ""

Expand All @@ -471,7 +471,7 @@ def to_string(self, event, is_public=False, **kwargs):
)
+ "\n\n"
)
return ("".join(output)).strip()
return "".join(output).strip()

def get_stacktrace(self, *args, **kwargs):
exc = self.values[-1]
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/interfaces/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ def to_json(self):
{"message": self.message, "formatted": self.formatted, "params": self.params or None}
)

def to_string(self, event, is_public=False, **kwargs):
def to_string(self, event) -> str:
return self.formatted or self.message
2 changes: 1 addition & 1 deletion src/sentry/interfaces/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def to_python(cls, data, **kwargs):
data.setdefault("effective_directive", None)
return super().to_python(data, **kwargs)

def to_string(self, is_public=False, **kwargs):
def to_string(self, event) -> str:
return orjson.dumps(
{"csp-report": self.get_api_context()},
option=orjson.OPT_UTC_Z | orjson.OPT_NON_STR_KEYS,
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/interfaces/stacktrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def is_unhashable_function(self):
# queries and JSON data)
return self.function.startswith(("lambda$", "[Anonymous"))

def to_string(self, event):
def to_string(self, event) -> str:
if event.platform is not None:
choices = [event.platform]
else:
Expand Down Expand Up @@ -525,7 +525,7 @@ def to_json(self):
}
)

def to_string(self, event, is_public=False, **kwargs):
def to_string(self, event) -> str:
return self.get_stacktrace(event, system_frames=False, max_frames=10)

def get_stacktrace(
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/interfaces/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def to_python(cls, data, **kwargs):

return super().to_python(data, **kwargs)

def to_string(self, event, is_public=False, **kwargs):
def to_string(self, event) -> str:
context = get_context(
lineno=self.lineno,
context_line=self.context_line,
Expand Down
2 changes: 1 addition & 1 deletion tests/sentry_plugins/victorops/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class UnicodeTestInterface(Interface):
def to_string(self, event):
def to_string(self, event) -> str:
return self.body

def get_title(self):
Expand Down
Loading