Skip to content

Commit e2a04cf

Browse files
committed
Revert "fix(analytics): exclude UUID from Event equality checks to allow for easier testing"
This reverts commit baf5a77.
1 parent 5755ef6 commit e2a04cf

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
lines changed

src/sentry/analytics/event.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def wrapper(cls: type[Event]) -> type[Event]:
6464
# set the Event subclass `type` attribute, if it is set to anything
6565
if isinstance(event_name_or_class, str):
6666
cls.type = event_name_or_class
67-
return cast(type[Event], dataclass(kw_only=True, eq=False)(cls))
67+
return cast(type[Event], dataclass(kw_only=True)(cls))
6868

6969
# for using without parenthesis, wrap the passed class
7070
if isinstance(event_name_or_class, type) and issubclass(event_name_or_class, Event):
@@ -75,7 +75,7 @@ def wrapper(cls: type[Event]) -> type[Event]:
7575

7676

7777
# unfortunately we cannot directly use `eventclass` here, as it is making a typecheck to Event
78-
@dataclass(kw_only=True, eq=False)
78+
@dataclass(kw_only=True)
7979
class Event:
8080
"""
8181
Base class for custom analytics Events.
@@ -123,18 +123,6 @@ def from_instance(cls, instance: Any, **kwargs: Any) -> Self:
123123
}
124124
)
125125

126-
def __eq__(self, other: Any) -> bool:
127-
if not isinstance(other, Event):
128-
return False
129-
130-
self_values = self.serialize()
131-
other_values = other.serialize()
132-
133-
self_values.pop("uuid")
134-
other_values.pop("uuid")
135-
136-
return self_values == other_values
137-
138126

139127
def serialize_event(event: Event) -> dict[str, Any]:
140128
# TODO: this is the "old-style" attributes based serializer. Once all events are migrated to the new style,

tests/sentry/analytics/test_event.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,6 @@ def test_simple(self, mock_uuid1):
5353
"uuid": b"AAEC",
5454
}
5555

56-
def test_equality_no_uuid_mock(self):
57-
a = ExampleEvent(
58-
id="1", # type: ignore[arg-type]
59-
map={"key": "value"},
60-
optional=False,
61-
)
62-
a.datetime_ = datetime(2001, 4, 18, tzinfo=timezone.utc)
63-
b = ExampleEvent(
64-
id="1", # type: ignore[arg-type]
65-
map={"key": "value"},
66-
optional=False,
67-
)
68-
b.datetime_ = datetime(2001, 4, 18, tzinfo=timezone.utc)
69-
assert a == b
70-
7156
@patch("sentry.analytics.event.uuid1")
7257
def test_simple_from_instance(self, mock_uuid1):
7358
mock_uuid1.return_value = self.get_mock_uuid()

0 commit comments

Comments
 (0)