Add utilities for merging dictionaries and deduplicating lists of items.

Review Request #11217 — Created Oct. 13, 2020 and submitted

Information

Django Evolution
master

Reviewers

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 into set(), 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
Add utilities for merging dictionaries and deduplicating lists of items.
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 into `set()`, 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.
2669cb334de31915c139e317273b4fe92f5c7af7
Description From Last Updated

E721 do not compare types, use 'isinstance()'

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (58cd060)