Skip to content

Conditional import of izip is problematic #1026

Closed
@gvanrossum

Description

@gvanrossum

Test code:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions