Unused type ignore comment are not displayed
Closed this issue · 3 comments
By using this code:
toto: int = "toto"
tata: int = 5 # type: ignore
The output of Mypy Type Checker
is:
2024-01-24 11:20:54.152 [info] file:///path/to/file/test.py :
/path/to/file/test.py:69:13:69:18: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
/path/to/file/test.py:70: error: Unused "type: ignore" comment [unused-ignore]
But only the first line has a visual feedback:
I suspect that the missing column may be the root cause as it is creating an empty range in the code.
Thanks, I'll look into it
First of all, are you sure you are using my extension ("Mypy") and not Microsoft's extension ("Mypy Type Checker")? I'm asking because you mentioned "Mypy Type Checker"...
Second - I can reproduce your issue in my extension, but it seems like a bug in mypy itself:
- I paste your code into a file and save it. I don't see any errors.
- I reload the window (causing mypy to be restarted). I see the error.
- I make a small change (e.g. changing 5 to 6) and save the file. I again don't see the error.
Examining the output panel, I see that it's dmypy itself that is at fault, it sometimes outputs the 'Unused type: ignore' and sometimes doesn't.
Thank you for taking the time to look at this. You are right, I used to rely on the daemon with this extension but the daemon had many issues. Since, I reverted back to the Microsoft's extension ("Mypy Type Checker"). Sorry for the disturbance.
According to your testing, it is a mypy daemon issue so I will close this issue anyway.
Note: It was a known issue on Microsoft's extension