Open
Description
In writing tests for #379, I stumbled over Asset objects not defining __eq__
.
In [1]: import pystac
In [2]: pystac.Asset(href='a') == pystac.Asset(href='a')
Out[2]: False
Looking briefly, I don't see it for any of the core items (a couple extensions define __eq__
). The behavior of Python is to fall back to object identity, (a is b
).
Should pystac objects define __eq__
(and __ne__
)? An implementation like the following probably makes sense:
def __eq__(self, other):
return type(self) == type(other) and self.to_dict() == other.to_dict()
If we define __eq__
then we may need to make the objects unhashable, since the objects are mutable. https://hynek.me/articles/hashes-and-equality/ is a good read on this.