-
-
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
Comparison chaining #439
Comparison chaining #439
Conversation
…nstead of always returning bool
…tors, which were are handled by ComparisonExpr
Thanks for the fix! I don't have time to review it right now, but I will do it later this week (I have time dedicated to mypy on Sunday). Can you have a look at the Travis CI failure (see Details above). Here is an extract -- it might be a mypy parser issue:
|
It think the errors at line 385 are caused by an existing bug in the mypy parser, which can be reproduced. mpf.py: ts = [(1,2), (3,4)]
xs = ['a', 'b']
for (t1, t2), x in zip(ts, xs):
print(t1, t2, x) Python runs fine:
But mypy fails to parse it:
I've created issue #441 for this. Lines 525 and 614 where not touched by me at all. |
Yeah, the mypy parser is to blame. For the time being, could you refactor it to use code that is supported by mypy, since otherwise mypy can't type check itself. For example, consider this: for (t1, t2), x in zip(ts, xs):
print(t1, t2, x) It can be written like this (though uglier): for t, x in zip(ts, xs):
t1, t2 = t
print(t1, t2, x) |
Thanks for the fix -- looks great! |
This fixes #309
I've added a new AST node,
ComparisonExpr
, for (chained) comparison expressions. This node is type checked as were it a boolean-and expression of pair-wise comparisons of all consecutive operands.