opsgenie-python-sdk icon indicating copy to clipboard operation
opsgenie-python-sdk copied to clipboard

Models do not override __hash__ making them unusable in hashed collections

Open asqui opened this issue 5 years ago • 1 comments

Models such as Responders define the __eq__() and __ne__() methods appropriately, but not __hash__().

From the Python documentation:

If a class [...] defines __cmp__() or __eq__() but not __hash__(), its instances will not be usable in hashed collections.

The practical consequence of this is that set((Responders(type='team', name='foo'))) != set((Responders(type='team', name='foo'))) which is quite confusing!

I suspect that this may be a bug coming from the Open Api Generator, but I am not familiar with the generator implementation and its use so am raising this bug here in the first instance.

asqui avatar Jan 29 '20 18:01 asqui

The fix for this is quite simple (see example here: https://github.com/BATS/opsgenie-python-sdk/commit/5fceef188fb4285b610c33a5646ea21206a3cee3) and it would be good if this could be fixed here so that I don't need to maintain a separate fork with the workaround for this issue...

asqui avatar Feb 05 '21 09:02 asqui