-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type error when creating a tuple from a Generator #5312
Comments
…thin an "expected type" should be used for bidirectional type inference. This addresses #5312.
…thin an "expected type" should be used for bidirectional type inference. This addresses #5312. (#5317) Co-authored-by: Eric Traut <[email protected]>
Thanks for the bug report. This is related to a heuristic that pyright uses when performing bidirectional type inference in the case where the "expected type" is a union. It currently assumes that if return type of the call (in this case the I've adjusted the heuristic so it works with this code. This will be addressed in the next release. |
Great -- thank you! |
This is included in pyright 1.1.315, which I just published. It will also be included in this week's insiders release of pylance. |
Describe the bug
Creating a
tuple[tuple[float, float]]
from aGenerator[tuple[float, float], None, None]
fails to type-check, unless a temporary variable is used.To Reproduce
I have an existing API which is typed like this:
If I use
tuple()
to turn a generator of converted points into an immutable sequence, I get the following error:However, capturing the created tuple in a temporary variable first prevents the error.
Expected behavior
I would expect equivalent type-checking results from
draw_path()
calls.VS Code extension or command-line
Command-line version 1.1.314
Additional context
#5281 could perhaps be related.
The text was updated successfully, but these errors were encountered: