-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Compat cmp dict fix #58729
Compat cmp dict fix #58729
Conversation
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 @11chrisadams11 thanks for the PR! This looks mostly great!
However - even (or especially?) for a change this small we are requiring tests. Should be just a couple of simple cases:
- - if x and y are equivalent (or copy) dicts, cmp should return 0
- - if x and y are not equivalent dicts, cmp should return -1 (maybe just do
cmp(x, y)
,cmp(y, x)
, andexpected_result = -1; assert result_one == result_two == expected_result
- - if x is a dict and y is not, or x is not and y is, ValueError (or TypeError?) should be raised.
Also, this will need a changelog entry, probably Fixed salt.utils.compat.cmp to work with dictionaries
or something to that effect.
HTH!
Sounds good. I wasn't sure if a test was required since there was not an existing one. I will get it added. |
I have added tests for my changes to compat.cmp, and added a changelog file. Let me know if there is anything else needed. Thanks |
Looks like a couple of test failures @11chrisadams11, mind looking into those? For pre-commit if you click on that and then check the console output it will tell you what's wrong. The freebsd122 isn't required so can probably be ignored - doesn't look like it's even able to find any image (but merging in the latest changes from the |
I made the changes required by the pre-commit check, and everything has passed now. |
All checks have passed now. Is there anything else needed from me for this? |
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.
🚀
When passed 2 dicts, the cmp function would fail with a TypeError of "'>' not supported between instances of 'dict' and 'dict'\n". This change adds a check for dict types and compares them with ==.
a26f5a0
to
363fdbf
Compare
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.
Moved tests to pytests and rebased... looks good
What does this PR do?
When passed 2 dicts, the cmp function would fail with a TypeError of "'>' not supported between instances of 'dict' and 'dict'\n". This change adds a check for dict types, compares them with ==, and returns a 0 or -1.
What issues does this PR fix or reference?
Using the boto_cfn state failed with Python 3 as it was trying to compare 2 dicts using compat.cmp
Previous Behavior
The boto_cfn state would fail with the following stack trace:
New Behavior
The state completes successfully
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
No
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.