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
In my source code I have to be Python2 and 3 compatible (this is the ruamel.yaml package) and I had a working definition for StreamType that boils down to this:
from StringIO import StringIO
if False: # MYPY
from typing import Any, Dict, Optional, List, Union, BinaryIO, IO, Text
StreamType = Union[BinaryIO, IO[str], StringIO]
(actually this is on line 120 of compat.py)
This started to give me an error:
ruamel/yaml/compat.py:120: error: Missing type parameters for generic type
As so often with mypy, I had no clue why I now got this error and how to fix it properly, so I added # type: ignore at the end of that line. I got distracted fixing some real code issues and the next day
I was trying to fix one of many, many more mypy reported errors, soon hitting one in util.py:
ruamel/yaml/util.py:120: error: Missing type parameters for generic type
And that line happens to have no code.
I added # type: ignore to line 119 in util.py (which has code), but the error would not go away. I started decimating the file to find at which line the actual problem occurred and the error stayed at line 120, even though the file had less than 40 lines. Once I hit line 16 and removed the line
from .compat import StreamTextType # NOQA
and realising that StreamTextType is derived from StreamType, I realised that the 120 was the line number from the compat.py file.
As I understand it the # type: ignore doesn't survive an import. Addign # type: ignore to the import line in util.py will add a note about unused type: ignore`` and the error persists.
For now I have to simplify the definition of StreamType to Any to be able to proceed as that fixed all the follow up errors ( 30+ of them), and I could revert the "fixes" for those that I implemented.
Although I am interested in the proper definition of StreamType, the bug with the line number being of a different file major, as it is extremely time consuming to find.
The text was updated successfully, but these errors were encountered:
Also, please note that StringIO.StringIO is generic in typeshed, so you should write StringIO[str] or StringIO[unicode] or similar. Or maybe you actually wanted typing.TextIO?
Here is a rather minimal set of test files and some commands with output.
The 40, in the last line, doesn't make sense at all, as the wc indicates
there are only 16 lines in that file.
$ mypy --version
mypy 0.650
$ uname -a
Linux pooh.mnt.org 4.1.4-040104-generic #201508031330 SMP Mon Aug 3 17:32:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ wc -l util.py
16 util.py
$ mypy --py2 --strict --follow-imports silent compat.py util.py
compat.py:40: error: Missing type parameters for generic type
util.py:40: error: Missing type parameters for generic type
Bug while using mypy 0.650
In my source code I have to be Python2 and 3 compatible (this is the ruamel.yaml package) and I had a working definition for
StreamType
that boils down to this:(actually this is on line 120 of
compat.py
)This started to give me an error:
As so often with mypy, I had no clue why I now got this error and how to fix it properly, so I added
# type: ignore
at the end of that line. I got distracted fixing some real code issues and the next dayI was trying to fix one of many, many more mypy reported errors, soon hitting one in
util.py
:And that line happens to have no code.
I added
# type: ignore
to line 119 inutil.py
(which has code), but the error would not go away. I started decimating the file to find at which line the actual problem occurred and the error stayed at line 120, even though the file had less than 40 lines. Once I hit line 16 and removed the lineand realising that
StreamTextType
is derived fromStreamType
, I realised that the 120 was the line number from thecompat.py
file.As I understand it the
# type: ignore
doesn't survive an import. Addign# type: ignore
to the import line inutil.py
will add a note aboutunused
type: ignore`` and the error persists.For now I have to simplify the definition of
StreamType
toAny
to be able to proceed as that fixed all the follow up errors ( 30+ of them), and I could revert the "fixes" for those that I implemented.Although I am interested in the proper definition of
StreamType
, the bug with the line number being of a different file major, as it is extremely time consuming to find.The text was updated successfully, but these errors were encountered: