Skip to content

Implement InputSource and OutputSource equality and hash methods

Moul requested to merge sources_equality_methods into dev

Here we are after moulte types errors!!


Implementation

In Silkaj, I need to check the equality of InputSource:

  • __eq__() implementation, to allow: inputsource1 == inputsource2

  • __hash__() methods should also be implemented. As I understood, it allows those classes stored into dict() and set() to continue working properly.

  • I also did it for OutputSource, as it’s pretty similar.


Readings


Types

I don’t if we can handle the type of the other argument. I tried, but I think it’s already checked with following block:

        if not isinstance(other, InputSource):
            return NotImplemented

In current code I found Any, and object.


One commit to change the return value within the equality method when it is not implemented between two different classes from False to NotImplemented.


Release

We can either wait for 0.54, or I can take care to release a 0.53.1.

Edited by Moul

Merge request reports