-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 narrowing for ellipsis via 'is ...' failing in 1.9.0 #17002
Labels
bug
mypy got something wrong
Comments
Probably related to python/typeshed#11223. I suspect some of these need to be updated:
|
hauntsaninja
added a commit
to hauntsaninja/mypy
that referenced
this issue
Mar 9, 2024
hauntsaninja
added a commit
that referenced
this issue
Mar 10, 2024
@dhirving Thank you for the issue. I'll add https://github.com/lsst/daf_butler to mypy_primer so we detect regressions against it |
Thanks for the prompt fix! I replied to the ticket on mypy_primer as well -- we'd love to be included in the regression suite. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
As of mypy 1.9.0, narrowing of unions containing
EllipsisType
via the expressionsif x is ...
orif x is Ellipsis
no longer works. In both branches of the if statement, the type ofx
still containsEllipsisType
instead of being narrowed.This narrowed as expected in 1.8.0.
As a workaround, it appears that
if instanceof(x, EllipsisType)
still works as expected.To Reproduce
Run mypy against the following snippet:
A more complicated reproduction of this issue can be seen in our repo here: https://github.com/lsst/daf_butler/actions/runs/8209898890/job/22456322445?pr=973
Expected Behavior
mypy 1.8.0 shows no errors because
x
was narrowed toint
in the else clause:Actual Behavior
mypy 1.9.0 reports an error instead:
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: