biocore / biocore/LabControl

Verify correctness of LabControlObject's __hash__ and __eq__ methods

Open
#494 1 comment 0 reactions 0 assignees View on GitHub
priority:low
Dominant language
Python
Stars
2
Forks
15
PR merge metrics
No merged PRs in 30d

Description

As @wasade has pointed out, the base class for most if not all of LabControl's classes is LabControlObject, and this object implements the __hash__ and __eq__ methods.

> On review of that code, I'm not convinced the __eq__ method is correct. The __hash__ is hash((self._table, self.id)) whereas __eq__ tests for equality of type() and the id property. This leads to a pathological edge case where two objects can have the same hash but not test equal if an the objects use the same table but have a different subclass. Similarly, this means that two objects can have a different hash, but test equal, if objects of the same type have different _table values.

I don't often implement __hash__ and __eq__ in classes, so I reviewed the code and tested it for myself and I've confirmed this to be true.

At @wasade's request, we should review/test the code and verify whether or not __eq__'s behavior should be changed to match __hash__ or not.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.