-
-
Notifications
You must be signed in to change notification settings - Fork 130
Closed
Labels
Milestone
Description
The simple statement from io import StringIO results in an error when running mypy checks.
$ coconut error.coco -s
Compiling error.coco ...
Compiled to error.py .
$ coconut error.coco -s --mypy
Compiling error.coco ...
Compiled to error.py .
error.py:22: error: Incompatible import of "StringIO" (imported name has type "Type[StringIO]", local name has type "T
ype[StringIO[Any]]")
$ cat error.coco
from io import StringIO
I did some investigation on this front. It looks like mypy is not terribly fond of imports in conditional blocks.
$ cat mypy-test-1.py
if False:
from StringIO import StringIO
else:
from io import StringIO
$ mypy --py2 mypy-test-1.py
mypy-test-1.py:4: error: Incompatible import of "StringIO" (imported name has type "Type[StringIO]", local name has type "Type[StringIO[Any]]")
$
$ cat mypy-test-2.py
from io import StringIO
$ mypy --py2 mypy-test-2.py
$
$ cat mypy-test-3.py
from StringIO import StringIO
from io import StringIO
$ mypy --py2 mypy-test-3.py
mypy-test-3.py:2: error: Incompatible import of "StringIO" (imported name has type "Type[StringIO]", local name has type "Type[StringIO[Any]]")