Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Add__hash__
method forpermissions.OperandHolder
class#9417
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
`OperandHolder` is not hashable, so need to add `__hash__` method
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.
lgtm, sorry being slow.
thanks anyway. merged as it was small, after cross checking |
We should really have tests for this.@vanya909 can you make a follow-up PR with a test that hashes an instance? |
Can you explain why using |
It's useful in cases when we want to filter out unique permissions in order to avoid calculating of some complex permissions two or more times Of course it can be done by just iterating over permissions list and appending in a result list those permissions which haven't been added yet, but using In case when we want to keep original order of permissions |
peterthomassen commentedJun 16, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Also, this fixes the regression introduced by#8710, so don't think it requires justification beyond that |
Uh oh!
There was an error while loading.Please reload this page.
OperandHolder
is not hashable, so need to add__hash__
methodDescription
OperandHolder
is not hashable after#8710, need to add__hash__
method to it to provide convenient syntax to filter unique permissions usingset
ordict.fromkeys
Ways to represent
Fixes
__eq__
method fromOperandHolder
or
__hash__
method toOperandHolder
Second way is provided in this PR