python-lsp / pylsp-mypy

Mypy plugin for the Python LSP Server.
MIT License
118 stars 35 forks source link

Thoughts on Incremental Mode #49

Closed StabbarN closed 1 year ago

StabbarN commented 1 year ago

What are your thoughts on adding support for incremental mode, more specifically flag cache-fine-grained?

IMO --cache-fine-grained would be great in LSP, even it's not perfect according to

If you use the mypy daemon, you may want to restart the daemon each time after the merge base or local branch has changed to avoid processing a potentially large number of changes in an incremental build, as this can be much slower than downloading cache data and restarting the daemon.

https://mypy.readthedocs.io/en/stable/additional_features.html#refinements

See also Caching with mypy daemon.

I noticed that --incremental is passed here https://github.com/python-lsp/pylsp-mypy/blob/0.6.4/pylsp_mypy/plugin.py#L213 but isn't incremental the default state? --no-incremental can be passed but I didn't find anything about --incremental. I also looked for incremental in the release notes at https://mypy-lang.blogspot.com/.

rchl commented 1 year ago

Not sure I fully understand. pylsp-mypy runs either in deamon or non-daemon mode. If we include --cache-fine-grained in non-daemon mode then how will it help user, if that user is not using the daemon mode?

In what specific cases it would be useful to have the --cache-fine-grained flag added? I would imagine that would have to be some case where user sometimes runs in non-daemon and sometimes in daemon mode but how would that work in practice?

StabbarN commented 1 year ago

Aaah, I misunderstood.

I would imagine that would have to be some case where user sometimes runs in non-daemon and sometimes in daemon mode but how would that work in practice?

Yeah, if one starts mypy in terminal by mypy --cache-fine-grained and then starts pylsp-mypy it would help. However, that wasn't my intention.

It probably doesn't make sense to use cache-fine-grained.