Conversation
uranusjr
left a comment
There was a problem hiding this comment.
Thanks for working on this! The fix makes sense to me.
| return NotImplemented | ||
|
|
||
| return self._spec == other._spec | ||
| return hash(self) == hash(other) |
There was a problem hiding this comment.
| return hash(self) == hash(other) | |
| return (self._spec[0], canonicalize_version(self._spec[1])) == (other._spec[0], canonicalize_version(other._spec[1])) |
seems cleaner to me than relying on hashes.
There was a problem hiding this comment.
Personally I like to rely on hash(), since it would be easier to add entries to _spec in the future (if this is ever needed) without the risk of forgetting to update both of them.
There was a problem hiding this comment.
I agree with @uranusjr, I think this is actually cleaner and more clear. And since they're doing essentially the same thing, I don't see any issue with relying on hash here (although maybe I'm missing something).
There was a problem hiding this comment.
Well hash() computes a hash meaning you could have a hash collision between two completely different versions.
I'd find something like:
def _canonical_keys(self):
return self._spec[0], canonicalize_version(self._spec[1])
def __eq__(self, other):
return self._canonical_keys == other._canonical_keys
def __hash__(self):
return hash(self._canonical_keys)
cleaner instead of relying on the huge hash space & hash randomization to avoid issues.
|
Thanks @di for the PR! Thanks @xavfernandez and @uranusjr for the reviews! I think it's perfectly fine to depend on I got to do the easy-and-fun part. ;) |
Fixes #282.