Skip to content

[python][bug] compatible logic for flatten doesn't work for model initialization #8994

Description

@msyyc

Python SDK models support three operations: initialization, getting attributes, and setting attributes. The Python team implemented compatibility mechanisms to preserve attribute getter/setter behavior.

# Before TypeSpec migration
model = Key(kty=...)
model.kty = "..."   # Set attribute
print(model.kty)    # Get attribute

# After TypeSpec migration - Initialization (Breaking Change)
model = Key(kty=...)                              # ❌ No longer supported
model = Key(properties=KeyProperties(kty=...))    # ✅ New required structure

# After TypeSpec migration - Attribute access (Backward Compatible)
model.kty = "..."                                 # ✅ Still works
print(model.kty)                                  # ✅ Still works

# After TypeSpec migration - Recommended approach
model.properties.kty = "..."                      # ✅ Recommended
print(model.properties.kty)                       # ✅ Recommended

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

emitter:client:pythonIssue for the Python client emitter: @typespec/http-client-python

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions