Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Make event objects unhashable
Browse files Browse the repository at this point in the history
Generally speaking one should look up an event by its id. Otherwise
we'll fall back to `object.__hash__` (the instance's address, under
CPython) which is probably not what you want.

Noticed in #15240.
  • Loading branch information
David Robertson committed Mar 21, 2023
1 parent 8f2a3cb commit e5afd0a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions synapse/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Generic,
Iterable,
List,
NoReturn,
Optional,
Sequence,
Tuple,
Expand Down Expand Up @@ -338,6 +339,9 @@ def __init__(
type: DictProperty[str] = DictProperty("type")
user_id: DictProperty[str] = DictProperty("sender")

def __hash__(self) -> NoReturn:
raise NotImplementedError()

@property
def event_id(self) -> str:
raise NotImplementedError()
Expand Down

0 comments on commit e5afd0a

Please sign in to comment.