Fix mutable default argument in check_if_part_exists_in_parts

Use None as default and initialize empty list inside the function to prevent mutable default argument anti-pattern.
This commit is contained in:
shuwen.wu 2026-09-02 18:04:17 +08:00
parent 59ea2a5792
commit 490390a057

View file

@ -613,11 +613,13 @@ def _get_equivalent_key(key: str, available_keys: set) -> str | None:
return None
def check_if_part_exists_in_parts(parts: list[PartType], part: PartType, excluded_keys: list[str] = []) -> bool:
def check_if_part_exists_in_parts(parts: list[PartType], part: PartType, excluded_keys: list[str] | None = None) -> bool:
"""
Check if a part exists in a list of parts
Handles both camelCase and snake_case key variations (e.g., function_call vs functionCall)
"""
if excluded_keys is None:
excluded_keys = []
keys_to_compare: Final = set(part.keys()) - set(excluded_keys)
for p in parts:
p_keys = set(p.keys())