Skip to content

Commit 4776ed1

Browse files
fix(core): preserve legitimate falsy values in _clean_empty (lint copilot review)
1 parent 8109b4d commit 4776ed1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/a2a/utils/helpers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,16 @@ def are_modalities_compatible(
350350
def _clean_empty(d: Any) -> Any:
351351
"""Recursively remove empty strings, lists and dicts from a dictionary."""
352352
if isinstance(d, dict):
353-
cleaned_dict = {k: cleaned_v for k, v in d.items() if (cleaned_v := _clean_empty(v)) is not None}
353+
cleaned_dict = {
354+
k: cleaned_v
355+
for k, v in d.items()
356+
if (cleaned_v := _clean_empty(v)) is not None
357+
}
354358
return cleaned_dict or None
355359
if isinstance(d, list):
356-
cleaned_list = [cleaned_v for v in d if (cleaned_v := _clean_empty(v)) is not None]
360+
cleaned_list = [
361+
cleaned_v for v in d if (cleaned_v := _clean_empty(v)) is not None
362+
]
357363
return cleaned_list or None
358364
if isinstance(d, str) and not d:
359365
return None

0 commit comments

Comments
 (0)