Add utilities for merging dictionaries and deduplicating lists of items.

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

chipx86
Django Evolution
master
django-evolution

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
Add utilities for merging dictionaries and deduplicating lists of items.
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
Review request changed

Change Summary:

Fixed an issue with some expected exceptions on Python 2.

Commits:

Summary
-
Add utilities for merging dictionaries and deduplicating lists of items.
+
Add utilities for merging dictionaries and deduplicating lists of items.

Diff:

Revision 3 (+514)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
david
  1. Ship It!
  2. 
      
Loading...