Compare commits

...

2 Commits

Author SHA1 Message Date
David Robertson
39d98249f4 Changelog 2023-03-21 22:31:39 +00:00
David Robertson
e5afd0ab99 Make event objects unhashable
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.
2023-03-21 22:23:08 +00:00
2 changed files with 5 additions and 0 deletions

1
changelog.d/15305.misc Normal file
View File

@@ -0,0 +1 @@
Make EventBase unhashable.

View File

@@ -24,6 +24,7 @@ from typing import (
Generic,
Iterable,
List,
NoReturn,
Optional,
Sequence,
Tuple,
@@ -338,6 +339,9 @@ class EventBase(metaclass=abc.ABCMeta):
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()