You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This error is correct. The behavior you're seeing is due to a recent bug fix. Pyright (the type checker that underlies pylance) previously contained a bug that resulted in a false negative. It failed to report an overlapping overload in this case. With this bug now fixed, it correctly reports the issue.
Until recently, there was no formal definition for an "overlapping overload" provided in the Python typing spec, but we've worked to address this omission. I wrote this new update to to the Python typing spec. Its contents have already gone through extensive review, and it's in its near-final form. Search for the "Overlapping Overloads" subsection if you're interested in the details.
The problem with your code sample is that both overloads specify a default value for the third parameter (split_stereo), so it's possible to call the function with just two arguments (those corresponding to parameters input_file and sampling_rate). In that case, the argument list would apply to both overloads, which makes it ambiguous. It might be easier to understand with a simplified example:
The problem with your code sample is that both overloads specify a default value for the third parameter (split_stereo), so it's possible to call the function with just two arguments (those corresponding to parameters input_file and sampling_rate). In that case, the argument list would apply to both overloads, which makes it ambiguous.
That's strange. Since the default value is False, shouldn't it be able to infer that it should take on the first overload if split_stereo is not specified?
This issue only starts appearing from Pylance 2024.9.1 and onwards. Works fine on 2024.8.2.
Environment data
Code Snippet
Expected behavior
No reports. This is a valid discriminated union.
Actual behavior
The text was updated successfully, but these errors were encountered: