Open allisonkarlitskaya opened 4 months ago
I think the solution to this issue is that pylsp-mypy
should just stop giving --follow-imports silent
: you actually lose some errors this way, even within a single file.
This would effectively be a revert to https://github.com/tomv564/pyls-mypy/pull/12. cc @eliwe.
Can you give an example for an error that would be lost?
Can you give an example for an error that would be lost?
After trying to reproduce this, I think I was wrong.
The error in question was several instances of var-annotated
, and I saw it reported after removing follow_imports = 'silent'
from my config, but the real difference was that I was using dmypy
instead of mypy
. I'm not sure why dmypy
reports an error where mypy
didn't, but I've been able to reproduce it that way now.
The reason I got confused is because of the reason I modified the config: follow_imports = 'silent'
is incompatible with dmypy
.
So, remove one reason for eliminating --follow-imports silent
(supposed extra messages) but add another: dmypy
compatibility. And indeed, pylsp-mypy
won't pass this argument when using dmypy
(but then, of course, you lose support for live updates...).
The default way that
mypy
gets invoked is with the arguments--show-error-end --no-error-summary --incremental --follow-imports silent
. Most of those are OK, but--follow-imports silent
will invalidate the cache if the same value isn't also present in the[tool.mypy]
section ofpyproject.toml
.The default value for this option is
normal
.The cache invalidation causes commandline invocations of
mypy
to take much longer after having opened the editor, and causes the editor to take longer after having runmypy
from the commandline.It's possible to reproduce this problem doing something like:
There's two workarounds for this, either (somewhat inelegantly) hack the value back to its default:
or just use 'silent' mode for all mypy invocations:
A third option is to give
mypy
a separate--cache-dir
when run frompylsp
, but this loses the benefit of sharing the cache between the two invocation modes (which is otherwise substantial).