-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Conflicting assertion causes (some) evaluations to stop #6931
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
Comments
Is there more I should share here in order to kick off the triage process? Have others tried been unable to repro the behavior? Happy to add more info or test cases, but this is a bug that results in silently stopping evaluation, which seems important to fix. |
What you do here is pretty magic, so no surprise mypy doesn't like it. Also this is essentially just a duplicate of #2395 |
It seems like something deeper is going on here, though. The other issue suggests that it's being treated this way because it's seen as unreachable code? Then why do other evaluations ( |
No, nothing deeper. Some messages are emitted during semantic analysis pass (like undefined names), while other during type checking (including |
The simple version of the problem may already be a known issue; I searched, but it's hard to know the right keywords. The more complex version at the end appears to be a novel bug AFAICT.
Conflicting assertions don't cause type reconsideration
This works:
A simple variable, asserted non-
None
, then changed to be None, correctly intuits its new type. (Nice!)Not to belabor the point, but even adding a bit of indirection (now
b
is in a class) still works, too:This does not work:
Indirectly modifying a variable and then re-
assert
ing its new types is not picked up.This also doesn't work if we try to hint that there's more going on under the hood by making
b
a@property
:Even
cast
ing the variable (inline or inkill
) doesn't make the typechecker pick up on its new type.Conflicting assertions cause (some) evaluations to stop altogether
But where it gets bizarre is if the conflicting assertion is in a block of some kind:
This one is kind of terrifying. It means anything else within that block now silently has disabled (or at least hobbled) type-checking.
Version Info
The text was updated successfully, but these errors were encountered: