-
Notifications
You must be signed in to change notification settings - Fork 91
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
action selection flag when patching #175
base: master
Are you sure you want to change the base?
Conversation
I would also like to have this functionality |
One could also just filter the diffs returnerd by diffs = dictdiffer.diff(a, b)
diffs = [diff for diff in diffs if diff[0] == 'add'] # Only do add operations
a = dictdiffer.patch(diffs, a) |
I think that may not work, as |
I can confirm that this works. I have done this for my project and it worked fine. I don't assume that import dictdiffer
a = {'a': 1}
b = {'b': 2}
diffs = dictdiffer.diff(a, b)
diffs = [diff for diff in diffs if diff[0] == 'add']
dictdiffer.patch(diffs, a) # Results in {'a': 1, 'b': 2} |
I see.Yes, it would work in the code example you provided. |
Description
Add action selection flag in the
dictdiffer.patch
function to allow selectively patching. For example, setaction_flags='a'
would only applyadd
items in thediffer_results
. See examples in thetest_limit_actions_patch
function in tests/test_utils.pyChecklist
Ticks in all boxes and 馃煝 on all GitHub actions status checks are required to merge:
Third-party code
If you've added third-party code (copy/pasted or new dependencies), please reach out to an architect.
Reminder
By using GitHub, you have already agreed to the GitHub鈥檚 Terms of Service including that: