Uh oh!
There was an error while loading. Please reload this page.
Fix for #1698 - #1989
Conversation
These tests started to fail because the condition analyzer is now smarter and was detecting some dead code on the tests that were supposed to generate some error messages.
The code in find_instance_check was made specifically for None related checks, but the new rule is more general so it should be indipendent of strict optional checking.
ddfisher
commented
Aug 5, 2016
Thanks for the PR! I'll take a detailed look at this early next week. |
| # the left operand is the result of the operator. | ||
| left_type = left_map[e.left] | ||
| truthiness_restriction = true_only | ||
| # type_restriction tells about the possible truth values of the left operand |
There was a problem hiding this comment.
I think you meant "truthiness_restriction".
ddfisher
commented
Aug 13, 2016
Sorry for the later-than-promised review. Overall, this looks great! That said, it introduces a weird bug: x=""ifnotx:
passifx:
passelse:
1+""# no error, indicating this branch is not typechecked/mypy thinks it can never occurI spent a little while looking into it, but it wasn't obvious where the problem was. I suspect it's related to some interaction with the |
dmoisset
commented
Aug 16, 2016
Thanks for the thorough review, I just see it (I was on holidays). I'll try On Sat, Aug 13, 2016 at 1:35 AM, David Fisher notifications@github.com
Daniel F. Moisset - UK Country Manager |
dmoisset
commented
Aug 16, 2016
I've added a few minor changes to fix the bug (it was a problem on |
| def join_simple(declaration: Type, s: Type, t: Type) -> Type: | ||
| """Return a simple least upper bound given the declared type.""" | ||
| if (s.can_be_true, s.can_be_false) != (t.can_be_true, t.can_be_false): |
There was a problem hiding this comment.
We probably need this for join_types also, right?
There was a problem hiding this comment.
I tried to test and couldn't make a failing case with join_type; I think
that one always creates new instances and new instances have always
undetermined boolean values. The problem with join_simple is that it was
reusing the existing types
There was a problem hiding this comment.
join_types also reuses existing values in some cases. I'd expect the same problem to exist, but just be pretty hard to actually repro.
ddfisher
commented
Aug 16, 2016
This is looking great! Just had a couple more small comments. |
dmoisset
commented
Aug 16, 2016
OK, I found a reproduction for join_types and added a test and a fix. (and your change to true_only) |
ddfisher
commented
Aug 16, 2016
Thanks! |
This is an implementation of my proposed fix for #1698 ( #1698 (comment) )
Relevant differences from the description there:
Typeinstead of wrapping Type objects. When I want to restrict a type I make a copy and override thecan_be_trueorcan_be_falsewith instance attributesnotafter realising that I couldn't find a relevant example where it helped. It's easy to add later if we discover otherwise but I didn't want to bloat an already large PRThere are some other improvements that I saw that could be made but I decided to stop here; if you think any of these are necessary I can add them:
Let me know what you think and if it's necessary to make further changes