[Python] Ensure necessary model imports#8006
Conversation
Internal models still get `__init__` overloads and still need the necessary imports. This changes the conditional check to use `need_init` which is more appropriate. This fixes the cases where all models are internal and `Mapping` and `overload` imports are missing in the generated `_models.py` file. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
|
@pvaneck After CI pass, please follow https://gist.github.com/msyyc/98b366435dbb2cf6a927074efe4b1f47 to create related PR in autorest.python repo to make sure this PR brings no bad impact for downstream emitter. |
.chronus/changes/typespec-internal-model-imports-2025-6-25-1-29-21.md
Outdated
Show resolved
Hide resolved
|
Hi @pvaneck there is no code diff in Azure/autorest.python#3152. Could you share the context or real service case that this PR tries to fix? |
|
Hey, @msyyc. I encountered the problem when constructing TypeSpec for the Azure.Monitor.Query service. This has a single operation, and in client.tsp, I have the operation marked as internal. This makes the associated models internal as well. After emitting the Python, the generated |
Internal models still get
__init__overloads and still need the necessary imports. This changes the conditional check to useneed_initwhich is more appropriate.This fixes the cases where all models are internal and
Mappingandoverloadimports are missing in the generated_models.pyfile.