dictknife
dictknife copied to clipboard
feat: new module, dictknife.sort -- for flexible sorting in diff check?
This pull request introduces a new flexible sorting mechanism in dictknife and provides comprehensive tests to ensure correctness and robustness. The main changes include the implementation of the sorting logic in dictknife/sort.py and the addition of unit tests in dictknife/tests/test_sort.py.
Sorting Mechanism Implementation:
-
Flexible Sorting Functionality: Added the
sort_flexiblyfunction, which can sort various data structures (lists, dictionaries, etc.) based on a consistent and hierarchical UID system. This includes helper classes (_Atom,_Collection,_Dict) to wrap and sort elements according to their type and value. (dictknife/sort.py, dictknife/sort.pyR1-R137)
Testing Enhancements:
-
Unit Tests for Wrapping Logic: Added a
WrapTestsclass to test the_wrapfunction, ensuring that elements are correctly wrapped and sorted based on their UID. (dictknife/tests/test_sort.py, dictknife/tests/test_sort.pyR1-R121) -
Unit Tests for Flexible Sorting: Added a
Testsclass to validate thesort_flexiblyfunction across a variety of input scenarios, including primitive types, nested structures, and missing values. (dictknife/tests/test_sort.py, dictknife/tests/test_sort.pyR1-R121)