-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Incorrect tuple type narrowing with len
(not an else case)
#9672
Comments
Pyright is working as intended here. The |
But there's no negative case here, the line with an error is always hit So there shouldn't be any narrowing |
There's always a positive and negative case. Here the negative case (the "not taken") is implied rather than explicit. You can see this must be the case if you were to replace the |
This sounds more like a technical detail rather than one coming from reasoning. The fact is, the I guess the merging that is done now is technically correct, but it results in a type that is not special-cased for indices as I also see that adding a |
Note: I've seen #9031, this is very similar, but also very different
Describe the bug
len()
ontuple[T, ...]
triggers some weird typeguard-like narrowing even outside the condition, where narrowing shouldn't happen at allCode or Screenshots
VS Code extension or command-line
CLI, 1.1.391
The text was updated successfully, but these errors were encountered: