I’m getting a mypy
syntax error on line 36 in every single one of my files. If the file is shorter than 36 lines it just highlights the last line. The error is invariably the same:
invalid syntax mypy(error)
Apparently this issue may have happened before, but without a clear solution. Is this a known bug? How can I fix this?
Here is a clear example:
Advertisement
Answer
I found the reason: I have another file where there is a syntax mistake on line 36. Even though I closed that file, somehow mypy
was still highlighting that same line in all of the files I had open. After I fixed that mistake in that one file, the mysterious syntax errors were gone in all the other files as well.
This seems like a bug to me, but I’m not sure if it’s mypy
or vscode (the IDE i’m using)? In any case my conclusion from this is: if you get inexplicable errors on the same line in all files, check for a mistake on that line even in closed files and fix it.