-
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
Support Union narrowing with Ellipsis #4397
Comments
Moving to pyright, since this is a core type checking issue. |
…...` and `x != ...`. Support for these were recently added to mypy. This addresses #4397.
This doesn't strike me as a common idiom in Python, but since support for this type guard was added to mypy recently, I think it's reasonable to add support in pyright as well. This will be addressed in the next release. |
Woops, sorry about that. Glad it's clean to move over.
So you have another usecase (outside of "mypy did it"), I did more digging. Thanks for the quick fix on this! |
This is addressed in pyright 1.1.288, which I just published. It will also be included in a future release of pylance. |
Effectively the same as this issue from mypy
Ellipsis is a constant in Python, so we're able to do identity checks on it for narrowing.
This allows supporting using Ellipsis as a sentinel value where
None
is an accepted input.basic example:
reveal_type output:
The text was updated successfully, but these errors were encountered: