Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.64k stars 2.84k forks source link

[Mgmt][Botservice] multi inheritance problem #24972

Open msyyc opened 2 years ago

msyyc commented 2 years ago

Describe the bug When initialize model Site, the following error will be raised:

>       super(WebChatSite, self).__init__(**kwargs)
E       TypeError: __init__() missing 2 required keyword-only arguments: 'site_name' and 'is_enabled'

To Reproduce Steps to reproduce the behavior: run the following code:

from azure.mgmt.botservice.models import Site

Site(
    is_v1_enabled=True,
    is_v3_enabled=True,
    site_name="xxx",
    is_enabled=True,
    is_webchat_preview_enabled=True,
    is_secure_site_enabled=True
)

Expected behavior The model could be initialized successfully

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

msyyc commented 2 years ago

The issue is related with python multi inheritance mechanism: https://github.com/Azure/azure-sdk-for-python/blob/ed8cb1754d5f91fd8ce7c2d9921d4dc3c960035a/sdk/botservice/azure-mgmt-botservice/azure/mgmt/botservice/models/_models_py3.py#L3085

During the parameter relay for super.__init__, but some keyword parameter will not be included in kwargs of next call. Therefore, even if we pass in site_name but WebChatSite can't get it in kwargs: image

Although it is not elegant, the possible fix is like: https://github.com/Azure/azure-sdk-for-python/blob/69c1ee770ee2eb6c66087d4d5127c00429e991cc/sdk/botservice/azure-mgmt-botservice/azure/mgmt/botservice/_patch.py#L91-L97

github-actions[bot] commented 5 months ago

Hi @msyyc, we deeply appreciate your input into this project. Regrettably, this issue has remained unresolved for over 2 years and inactive for 30 days, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.