Closed ghost closed 6 years ago
Thanks for the pull request. Is there a reason that this comparison can't be performed without using __eq__
i.e. comparing the attributes individually? I'm somewhat hesitant to change this since it would change the existing behaviour. I wouldn't expect anybody to be relying on the current behaviour, but this seems like a small issue to break backwards compatibility over.
In case it's useful, some feedback on the code itself:
if you're implementing __eq__
, you should be implementing __ne__
and __hash__
(if we made the class immutable) as well.
the normal approach I've seen to implementing __eq__
is to check the type of the other value, and then to compare attributes explicitly, rather than comparing __dict__
.
changes should be covered by tests
Closing for now, but happy to reconsider. Feel free to leave further comments.
This commit adds a method to the ExecutionResult class to allow result classes to be compared and determine if they are equal (contain the exact same values in their attributes). This is useful when tracking multiple results over many SSH connections and also when trying to maintain persistence. When results are stored it is useful to be able to compare to see if data has been changed in any way.