Skip to content

chore(typing): Set 13 #68717

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

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ module = [
"sentry.buffer.redis",
"sentry.eventstore.reprocessing.redis",
"sentry.grouping.fingerprinting",
"sentry.grouping.variants",
"sentry.issues.related.*",
"sentry.lang.java.processing",
"sentry.migrations.*",
Expand Down
32 changes: 17 additions & 15 deletions src/sentry/grouping/variants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from typing import Any

from sentry.grouping.utils import hash_from_values, is_default_fingerprint_var
from sentry.types.misc import KeyedList

Expand All @@ -15,18 +17,18 @@ def get_hash(self) -> str | None:
return None

@property
def description(self):
def description(self) -> str | None:
return self.type

def _get_metadata_as_dict(self):
def _get_metadata_as_dict(self) -> dict[Any, Any]:
return {}

def as_dict(self):
def as_dict(self) -> dict[str, str | None]:
rv = {"type": self.type, "description": self.description, "hash": self.get_hash()}
rv.update(self._get_metadata_as_dict())
return rv

def __repr__(self):
def __repr__(self) -> str:
return f"<{self.__class__.__name__} {self.get_hash()!r} ({self.type})>"


Expand All @@ -36,14 +38,14 @@ def __repr__(self):
class ChecksumVariant(BaseVariant):
"""A checksum variant returns a single hardcoded hash."""

type = "checksum"
type: str = "checksum"

def __init__(self, hash, hashed=False):
def __init__(self, hash, hashed=False) -> None:
self.hash = hash
self.hashed = hashed

@property
def description(self):
def description(self) -> str:
if self.hashed:
return "hashed legacy checksum"
return "legacy checksum"
Expand Down Expand Up @@ -75,7 +77,7 @@ class PerformanceProblemVariant(BaseVariant):
description = "performance problem"
contributes = True

def __init__(self, event_performance_problem):
def __init__(self, event_performance_problem) -> None:
self.event_performance_problem = event_performance_problem
self.problem = event_performance_problem.problem

Expand All @@ -96,7 +98,7 @@ class ComponentVariant(BaseVariant):

type = "component"

def __init__(self, component, config):
def __init__(self, component, config) -> None:
self.component = component
self.config = config

Expand Down Expand Up @@ -142,7 +144,7 @@ class CustomFingerprintVariant(BaseVariant):

type = "custom-fingerprint"

def __init__(self, values, fingerprint_info=None):
def __init__(self, values, fingerprint_info=None) -> None:
self.values = values
self.info = fingerprint_info

Expand All @@ -153,7 +155,7 @@ def description(self):
def get_hash(self) -> str | None:
return hash_from_values(self.values)

def _get_metadata_as_dict(self):
def _get_metadata_as_dict(self) -> dict[str, Any]:
return expose_fingerprint_dict(self.values, self.info)


Expand All @@ -163,7 +165,7 @@ class BuiltInFingerprintVariant(CustomFingerprintVariant):
type = "built-in-fingerprint"

@property
def description(self):
def description(self) -> str:
return "Sentry defined fingerprint"


Expand All @@ -172,13 +174,13 @@ class SaltedComponentVariant(ComponentVariant):

type = "salted-component"

def __init__(self, values, component, config, fingerprint_info=None):
def __init__(self, values, component, config, fingerprint_info=None) -> None:
ComponentVariant.__init__(self, component, config)
self.values = values
self.info = fingerprint_info

@property
def description(self):
def description(self) -> str:
return "modified " + self.component.description

def get_hash(self) -> str | None:
Expand All @@ -192,7 +194,7 @@ def get_hash(self) -> str | None:
final_values.append(value)
return hash_from_values(final_values)

def _get_metadata_as_dict(self):
def _get_metadata_as_dict(self) -> dict[str, Any]:
rv = ComponentVariant._get_metadata_as_dict(self)
rv.update(expose_fingerprint_dict(self.values, self.info))
return rv
Expand Down