You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try:
from itertools import izip
except ImportError:
izip = zip
In Python 3 mode, this complains that itertools doesn't define izip. This is correct but maybe inside try/except ImportError this should not be an error.
In Python 2 mode, this gives the dreaded "Incompatible types" errror:
/Users/guido/mypy_tests/mypy_izip.py:4: error: Incompatible types in assignment (expression has type overloaded function, variable has type overloaded function)
I guess this is another case of #649 that isn't handled yet.
The text was updated successfully, but these errors were encountered:
Yeah, we could consider this is special case of #649, but we can keep ImportError related problems where mypy should ignore a block separate in this issue. #649 can cover cases where all conditional definitions should take effect.
Another related case that is pretty common in Python 2 std library code is shown below. In this case both imports work, but mypy can't deal with a multiply defined class. Maybe we should just ignore one of the class definitions here for now, and maybe give an optional warning in the future:
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
Test code:
In Python 3 mode, this complains that itertools doesn't define izip. This is correct but maybe inside
try/except ImportError
this should not be an error.In Python 2 mode, this gives the dreaded "Incompatible types" errror:
I guess this is another case of #649 that isn't handled yet.
The text was updated successfully, but these errors were encountered: