Azure-Samples / cognitive-services-speech-sdk

Sample code for the Microsoft Cognitive Services Speech SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyright complains about type hints in azure speech SDK

msehnout opened this issue · comments

Describe the bug

pyright, the static type checker from Microsoft, complains about the default values in speech SDK methods, consider this as an example:

class AudioOutputConfig():
    """
    ...
    """

    def __init__(self, use_default_speaker: bool = False, filename: str = None,
                 stream: AudioOutputStream = None, device_name: str = None):

The type hints are incorrect because they assume all objects are implicitly nullable which is where pyright disagrees:

error: Argument of type "None" cannot be assigned to parameter "stream" of type "AudioOutputStream" in function "__init__"
    "None" is incompatible with "AudioOutputStream" (reportArgumentType)

Speech SDK should use correct type hints with explicit nullability like this:

def __init__(self, use_default_speaker: bool = False, filename: str | None = None,
                 stream: AudioOutputStream | None = None, device_name: str | None = None):

Thanks for reporting this issue, we will fix it

This item has been open without activity for 19 days. Provide a comment on status and remove "update needed" label.