@@ -38,8 +38,17 @@ def compare_config(
38
38
:return: a ConfigChange objects.
39
39
"""
40
40
diff = defaultdict (list [LibraryChange ])
41
- baseline_params = __convert_params_to_sorted_list (baseline_config )
42
- current_params = __convert_params_to_sorted_list (current_config )
41
+ # Exclude `libraries` because an empty library list (e.g., by library
42
+ # removal) will cause this parameter appears in the sorted param list,
43
+ # which leads to unequal list of parameters.
44
+ excluded_params = {"libraries" }
45
+ baseline_params = __convert_params_to_sorted_list (
46
+ obj = baseline_config , excluded_params = excluded_params
47
+ )
48
+ current_params = __convert_params_to_sorted_list (
49
+ obj = current_config , excluded_params = excluded_params
50
+ )
51
+
43
52
for baseline_param , current_param in zip (baseline_params , current_params ):
44
53
if baseline_param == current_param :
45
54
continue
@@ -216,7 +225,7 @@ def __compare_gapic_configs(
216
225
diff [ChangeType .GAPIC_ADDITION ].append (config_change )
217
226
218
227
219
- def __convert_params_to_sorted_list (obj : Any ) -> List [tuple ]:
228
+ def __convert_params_to_sorted_list (obj : Any , excluded_params = None ) -> List [tuple ]:
220
229
"""
221
230
Convert the parameter and its value of a given object to a sorted list of
222
231
tuples.
@@ -230,13 +239,17 @@ def __convert_params_to_sorted_list(obj: Any) -> List[tuple]:
230
239
231
240
Note that built-in params, e.g., __str__, and methods will be skipped.
232
241
233
- :param obj: an object
242
+ :param obj: an object.
243
+ :param excluded_params: excluded params.
234
244
:return: a sorted list of tuples.
235
245
"""
246
+ if excluded_params is None :
247
+ excluded_params = set ()
236
248
param_and_values = []
237
249
for param , value in vars (obj ).items ():
238
250
if (
239
- param .startswith ("__" ) # skip built-in params
251
+ param in excluded_params
252
+ or param .startswith ("__" ) # skip built-in params
240
253
or callable (getattr (obj , param )) # skip methods
241
254
# skip if the type of param is not one of the following types
242
255
# 1. str
0 commit comments