Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,9 @@ def todict(obj, post_processor=None):
return obj.isoformat()
if isinstance(obj, timedelta):
return str(obj)
# This is the only difference with knack.util.todict because for typespec generated SDKs
if azure.core.serialization.is_generated_model(obj):
result = {to_camel_case(k): todict(getattr(obj, k), post_processor) for k in azure.core.serialization.as_attribute_list(obj)}
return post_processor(obj, result) if post_processor else result # This is the only difference with knack.util.todict because for typespec generated SDKs
Comment on lines +648 to +649
Copy link

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dict comprehension is quite long and the inline comment on the next line makes it harder to read. Consider breaking it into multiple lines or moving the comment above the return statement to improve readability according to the 856 guideline.

Suggested change
result = {to_camel_case(k): todict(getattr(obj, k), post_processor) for k in azure.core.serialization.as_attribute_list(obj)}
return post_processor(obj, result) if post_processor else result # This is the only difference with knack.util.todict because for typespec generated SDKs
result = {
to_camel_case(k): todict(getattr(obj, k), post_processor)
for k in azure.core.serialization.as_attribute_list(obj)
}
# This is the only difference with knack.util.todict because for typespec generated SDKs
return post_processor(obj, result) if post_processor else result

Copilot uses AI. Check for mistakes.
# The base model stores data in obj.__dict__['_data'] instead of in obj.__dict__
# We need to call obj.as_dict() to extract data for this kind of model
if hasattr(obj, 'as_dict') and not hasattr(obj, '_attribute_map'):
Expand Down
Loading