-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure audb.Repository is hashable #491
Conversation
Reviewer's Guide by SourceryThe PR implements hashability for the Class diagram for audb.Repository with hashabilityclassDiagram
class Repository {
+__eq__(other) bool
+__hash__() int
+__repr__() str
}
note for Repository "Added __hash__ method to enable hashability"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @hagenw - I've reviewed your changes - here's some feedback:
Overall Comments:
- The test case comparing set([repository]) to set([str(repository)]) is incorrect - these will never be equal since they contain different types. Consider testing set operations with Repository objects instead, e.g. set([repository]) == set([repository])
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one question:
when reading the code, I thought that you actually are about to implement __eq__
.
I don't know what the default implementation of __eq__
is, but this post suggests that
it is ==
.
Would it then not make sense to use __hash__
to calculate __eq__
in the same issue?
|
Ah so
Conceptually it was more intuitive to me to have I close the issue not the thread. Reopening. |
Sorry I closed the MR and not the thread. Reopened. |
As you are ok with |
Yes, using |
As
audb.config.REPOSITORIES
is given as a list of repositories, one would expectset(audb.config.REPOSITORIES)
to work as well, which is not the case at the moment. It is solved in this pull request by adding a__hash__()
method toaudb.Repository
.Summary by Sourcery
Make audb.Repository hashable by implementing the hash method and add a test to ensure its hashability.
Enhancements:
Tests: