-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Description
Steps to reproduce
- Create two equal objects. E. g.:
user1 = User(id=1, first_name="Equal", last_name="Identical", username="same", type=None, bot=None)
user2 = User(id=1, first_name="Equal", last_name="Identical", username="same", type=None, bot=None)
- Compare the objects:
assert user1 == user2
Expected behaviour
The assertion should pass: The equality comparison should return True
.
Actual behaviour
The assertion fails:
> assert user1 == user2
E assert <telegram.use...at 0x041006F0> == <telegram.user...at 0x041006D0>
Configuration
Operating System:
Windows 10
Version of Python, python-telegram-bot & dependencies:
Python 3.6.1
python-telegram-bot commit 4541476
Possible fix
Implementing the rich comparison method __eq__
for the class. Implementing __hash__
alongside might be a good idea.
Notes
This probably not only holds for the User
object, but for all Telegram objects.
Metadata
Metadata
Assignees
Labels
No labels