Add utilities for merging dictionaries and deduplicating lists of items.
Review Request #11217 — Created Oct. 13, 2020 and submitted
This introduces a couple of new datastructure-related utility functions
that will be used in some upcoming changes.
filter_dup_list_items()
takes a list of items and filters out any
duplicates, ensuring that there is one of each instance in the list.
This is similar to passing a list intoset()
, but preserves the order.
merge_dicts()
merges two dictionaries together. Its approach is
simplistic but sufficient for our needs. Keys present only in the source
dictionary are placed in the destination. Lists are concatenated.
Dictionaries are recursively merged. Anything else triggers an error.Unit tests and doc generation were added for these new functions.
Unit tests pass.
Tested these in upcoming changes.
Summary | ID |
---|---|
2669cb334de31915c139e317273b4fe92f5c7af7 |
Description | From | Last Updated |
---|---|---|
E721 do not compare types, use 'isinstance()' |
reviewbot |
- Change Summary:
-
- Replaced an
assert type is type
check with more specific checks that result in more useful exceptions. - Added "Version Added" sections in the docstrings.
- Replaced an
- Commits:
-
Summary ID f1ead5bb911c812e8a9d42a0ca5a4da35274aa9f 6f628bbed56c43c177a007a0c1721b7da7cd1b5f