Skip to content

Conversation

@lmazuel
Copy link
Member

@lmazuel lmazuel commented Jun 26, 2025

Current email thread with @evelyn-ys , DO NOT MERGE

Copilot AI review requested due to automatic review settings June 26, 2025 23:50
@azure-client-tools-bot-prd
Copy link

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd
Copy link

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Collaborator

yonzhan commented Jun 26, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for serializing TypeSpec-generated SDK models in the todict utility by detecting generated models and converting their attributes.

  • Introduces a new if azure.core.serialization.is_generated_model(obj) branch to handle TypeSpec models.
  • Builds a camel-cased dictionary from model attributes via as_attribute_list.
  • Applies an optional post_processor to the serialized result.
Comments suppressed due to low confidence (1)

src/azure-cli-core/azure/cli/core/util.py:647

  • There are no existing tests covering the new is_generated_model branch. Please add unit tests to verify that TypeSpec-generated models are correctly serialized through this path.
    if azure.core.serialization.is_generated_model(obj):

Comment on lines +648 to +649
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
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.
@evelyn-ys
Copy link
Member

dup with #31775

@evelyn-ys evelyn-ys closed this Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants