semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Python: @overload decorator is missing on AzureTextEmbedding and OpenAITextEmbedding class.

Open chnldw opened this issue 2 years ago • 5 comments

Describe the bug @overload decorator is missing on AzureTextEmbedding and OpenAITextEmbedding class.

https://github.com/microsoft/semantic-kernel/blob/563e1809e27c8bb918d605eaba9916d25e2cb478/python/semantic_kernel/connectors/ai/open_ai/services/azure_text_embedding.py#L45

https://github.com/microsoft/semantic-kernel/blob/563e1809e27c8bb918d605eaba9916d25e2cb478/python/semantic_kernel/connectors/ai/open_ai/services/open_ai_text_embedding.py#L39

To Reproduce pyright would report this error

code

AzureTextEmbedding(
    deployment_name=openai_config.model_id,
    endpoint=openai_config.api_endpoint,
    api_key=openai_config.api_key,
    api_version=openai_config.api_version,
)

error

Initialize an AzureChatCompletion service.

Arguments:
    deployment_name: The name of the Azure deployment. This value
        will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under Resource Management > Deployments in the Azure portal or, alternatively, under Management > Deployments in Azure OpenAI Studio.
    async_client {AsyncAzureOpenAI} -- An existing client to use.
    log: The logger instance to use. (Optional)

Expected behavior pyright shouldn't report any error.

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

Platform

  • OS: Windows
  • IDE: VS Code
  • Language: Python
  • Source: pip 0.4.2.dev0

Additional context Add any other context about the problem here.

chnldw avatar Dec 15 '23 00:12 chnldw

Hi @chnldw, thanks for filing this. Could you let me know what the issue is?

We use @overload to declare different signatures of the same method. These declarations are like stubs and don't contain the actual implementation. They guide static type checkers and improve code readability.

The actual implementation of the method (in this case, the constructor) does not use @overload. That is why you see the constructor without decorator.

moonbox3 avatar Dec 15 '23 20:12 moonbox3

Thanks @moonbox3

Yes, the impact is type checking. pyright would report this error

code

AzureTextEmbedding(
    deployment_name=openai_config.model_id,
    endpoint=openai_config.api_endpoint,
    api_key=openai_config.api_key,
    api_version=openai_config.api_version,
)

error

Initialize an AzureChatCompletion service.

Arguments:
    deployment_name: The name of the Azure deployment. This value
        will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under Resource Management > Deployments in the Azure portal or, alternatively, under Management > Deployments in Azure OpenAI Studio.
    async_client {AsyncAzureOpenAI} -- An existing client to use.
    log: The logger instance to use. (Optional)

chnldw avatar Jan 03 '24 00:01 chnldw

@eavanvalkenburg can you provide any insight here, please?

moonbox3 avatar Jan 03 '24 17:01 moonbox3

which python version are you using and how are you running pyright? @chnldw

eavanvalkenburg avatar Jan 03 '24 20:01 eavanvalkenburg

As we haven't had a response on this in almost two months, closing this issue. If there is still a problem, please re-open the issue, or file a new one. Thank you.

moonbox3 avatar Feb 26 '24 17:02 moonbox3