@@ -64,8 +64,12 @@ def fix_deepdiff_key_names(obj: Mapping) -> Dict:
64
64
result = {} # type: Dict
65
65
for key , value in obj .items ():
66
66
key_parts = re .findall (REGEX_PATTERN_RELEVANT_KEYS , key )
67
- if not key_parts : # If key parts can't be find, keep original key so data is not lost.
68
- key_parts = [key .replace ("root" , "index_element" )] # replace root from DeepDiff with more meaningful name.
67
+ if (
68
+ not key_parts
69
+ ): # If key parts can't be find, keep original key so data is not lost.
70
+ key_parts = [
71
+ key .replace ("root" , "index_element" )
72
+ ] # replace root from DeepDiff with more meaningful name.
69
73
partial_res = group_value (key_parts , value )
70
74
dict_merger (result , partial_res )
71
75
return result
@@ -81,10 +85,16 @@ def group_value(tree_list: List, value: Dict) -> Dict:
81
85
def dict_merger (original_dict : Dict , dict_to_merge : Dict ):
82
86
"""Function to merge a dictionary (dict_to_merge) recursively into the original_dict."""
83
87
for key in dict_to_merge .keys ():
84
- if key in original_dict and isinstance (original_dict [key ], dict ) and isinstance (dict_to_merge [key ], dict ):
88
+ if (
89
+ key in original_dict
90
+ and isinstance (original_dict [key ], dict )
91
+ and isinstance (dict_to_merge [key ], dict )
92
+ ):
85
93
dict_merger (original_dict [key ], dict_to_merge [key ])
86
94
elif key in original_dict .keys ():
87
- original_dict [key + "_dup!" ] = dict_to_merge [key ] # avoid overwriting existing keys.
95
+ original_dict [key + "_dup!" ] = dict_to_merge [
96
+ key
97
+ ] # avoid overwriting existing keys.
88
98
else :
89
99
original_dict [key ] = dict_to_merge [key ]
90
100
@@ -122,30 +132,18 @@ def set_nested_value(data, keys, value):
122
132
set_nested_value (data [keys [0 ]], keys [1 :], value )
123
133
124
134
125
- def all_values_empty (input_dict ):
126
- """
127
- Checks if all values in a dictionary are empty objects (empty string, list, or dictionary).
128
-
129
- Args:
130
- input_dict: The dictionary to check.
131
-
132
- Returns:
133
- True if all values are empty, False otherwise.
134
- """
135
- for value in input_dict .values ():
136
- if value : # Empty objects evaluate to False in a boolean context
137
- return False
138
- return True
139
-
140
-
141
135
def parse_diff (jdiff_evaluate_response , actual , intended , match_config ):
142
136
"""Parse jdiff evaluate result into missing and extra dictionaries."""
143
137
extra = {}
144
138
missing = {}
145
139
146
140
def process_diff (_map , extra_map , missing_map , previous_key = None ):
147
141
for key , value in _map .items ():
148
- if isinstance (value , dict ) and "new_value" in value and "old_value" in value :
142
+ if (
143
+ isinstance (value , dict )
144
+ and "new_value" in value
145
+ and "old_value" in value
146
+ ):
149
147
extra_map [key ] = value ["old_value" ]
150
148
missing_map [key ] = value ["new_value" ]
151
149
elif isinstance (value , str ):
0 commit comments