diff --git a/scripts/clean_metadata.py b/scripts/clean_metadata.py index 0a9bcb2be..73ba2b713 100755 --- a/scripts/clean_metadata.py +++ b/scripts/clean_metadata.py @@ -182,15 +182,33 @@ def main(): # Generate unified diff # If dictionaries differ, generate JSON strings to show the diff - litellm_json = json.dumps(litellm_entry, indent=4, sort_keys=True).splitlines() - aider_json = json.dumps(aider_entry, indent=4, sort_keys=True).splitlines() + # Add a dummy key to ensure the *real* last key gets a comma + litellm_entry_copy = litellm_entry.copy() + aider_entry_copy = aider_entry.copy() + dummy_key = "zzzdummykey" + litellm_entry_copy[dummy_key] = True + aider_entry_copy[dummy_key] = True + + litellm_json_lines = json.dumps( + litellm_entry_copy, indent=4, sort_keys=True + ).splitlines() + aider_json_lines = json.dumps( + aider_entry_copy, indent=4, sort_keys=True + ).splitlines() + + # Remove the dummy key line before diffing + litellm_json_filtered = [ + line for line in litellm_json_lines if dummy_key not in line + ] + aider_json_filtered = [line for line in aider_json_lines if dummy_key not in line] + diff = difflib.unified_diff( - aider_json, - litellm_json, + aider_json_filtered, + litellm_json_filtered, fromfile=f"{key} (aider)", tofile=f"{key} (litellm)", lineterm="", - n=max(len(litellm_json), len(aider_json)), # Show all lines + n=max(len(litellm_json_filtered), len(aider_json_filtered)), # Show all lines ) # Print the diff, skipping the header lines generated by unified_diff