src/nitpick/formats.py
def compare_with_dictdiffer(
        self, expected: Union[JsonDict, "BaseFormat"] = None, transform_function: Callable = None
    ) -> Comparison:
        """Compare two structures and compute missing and different items using ``dictdiffer``."""
        comparison = self._create_comparison(expected)

        comparison.missing_dict = SortedDict()
        comparison.diff_dict = SortedDict()
        for diff_type, key, values in dictdiffer.diff(comparison.flat_actual, comparison.flat_expected):
            if diff_type == dictdiffer.ADD:
                comparison.missing_dict.update(dict(values))
            elif diff_type == dictdiffer.CHANGE:
                raw_actual, raw_expected = values
                actual_value, expected_value = comparison.format_class.cleanup(raw_actual, raw_expected)
                if actual_value != expected_value:
                    comparison.update_pair(key, raw_expected)

        missing = transform_function(comparison.missing_dict) if transform_function else comparison.missing_dict
        comparison.set_missing(missing)
        comparison.set_diff(comparison.diff_dict)
        return comparison
Compare two structures and compute missing and different items using ``dictdiffer``.
Compare two structures and compute missing and different items using ``dictdiffer``.
Compare two structures and compute missing and different items using ` ` dictdiffer ` ` .
def compare_with_dictdiffer(
        self, expected: Union[JsonDict, "BaseFormat"] = None, transform_function: Callable = None
    ) -> Comparison:
        comparison = self._create_comparison(expected)
        comparison.missing_dict = SortedDict()
        comparison.diff_dict = SortedDict()
        for diff_type, key, values in dictdiffer.diff(comparison.flat_actual, comparison.flat_expected):
            if diff_type == dictdiffer.ADD:
                comparison.missing_dict.update(dict(values))
            elif diff_type == dictdiffer.CHANGE:
                raw_actual, raw_expected = values
                actual_value, expected_value = comparison.format_class.cleanup(raw_actual, raw_expected)
                if actual_value != expected_value:
                    comparison.update_pair(key, raw_expected)
        missing = transform_function(comparison.missing_dict) if transform_function else comparison.missing_dict
        comparison.set_missing(missing)
        comparison.set_diff(comparison.diff_dict)
        return comparison
def compare_with_dictdiffer ( self , expected : Union [ JsonDict , "BaseFormat" ] = None , transform_function : Callable = None ) -> Comparison : comparison = self . _create_comparison ( expected ) comparison . missing_dict = SortedDict ( ) comparison . diff_dict = SortedDict ( ) for diff_type , key , values in dictdiffer . diff ( comparison . flat_actual , comparison . flat_expected ) : if diff_type == dictdiffer . ADD : comparison . missing_dict . update ( dict ( values ) ) elif diff_type == dictdiffer . CHANGE : raw_actual , raw_expected = values actual_value , expected_value = comparison . format_class . cleanup ( raw_actual , raw_expected ) if actual_value != expected_value : comparison . update_pair ( key , raw_expected ) missing = transform_function ( comparison . missing_dict ) if transform_function else comparison . missing_dict comparison . set_missing ( missing ) comparison . set_diff ( comparison . diff_dict ) return comparison
Compare two structures and compute missing and different items using ``dictdiffer``.
Compare two structures and compute missing and different items using ` ` dictdiffer ` ` .
"""Compare two structures and compute missing and different items using ``dictdiffer``."""
self
expected
Union[JsonDict, "BaseFormat"]
transform_function
Callable