python-lsp / pylsp-mypy

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

Add configuration via lsp guide to README #78

Closed LaurenceWarne closed 4 weeks ago

LaurenceWarne commented 6 months ago

Hi, this PR is in response to https://github.com/python-lsp/pylsp-mypy/issues/32, I've added a description for how the plugin can be configured (to the best of my understanding :slightly_smiling_face:) using lsp, and given an example similar to that given in https://github.com/python-lsp/python-lsp-ruff#configuration.

Thanks!

Richardk2n commented 4 months ago

This is editor dependent, is it not? I am not sure if we are responsible to provide documentation for that. In my opinion, the editor should do this. If we do, we would need to cover a few relevant editors. The preferred style (sadly badly documented here) is using pyproject.toml. Maybe I should expand on that a little more, but I am not too keen on encouraging the use of esoteric command line editors.

LaurenceWarne commented 4 months ago

I am not sure if we are responsible to provide documentation for that.

Yes it will be editor depedendent, I guess I was mainly trying to address that AFAICS the README config section doesn't mention that configuration from LSP is supported at all.

Maybe I should expand on that a little more, but I am not too keen on encouraging the use of esoteric command line editors.

I'm happy to drop the example. How about doing something similar to https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md by sticking the configuration options in a table with the relevant configuration keys? e.g.:

pyproject.toml key LSP configuration key Type Description Default
live_mode pylsp.plugins.pylsp_mypy boolean This writes to a tempfile every time a check is done. Turning off live_mode means you must save your changes for mypy diagnostics to update correctly. True

etc

nramirezuy commented 3 months ago

@LaurenceWarne do you know how to handle overrides?

 pylsp_mypy = {
    enabled = true,
    overrides = {"--python-executable", "python"},
 }

This ends up with this: image

But if I configure it through pyproject.toml works as expected. :thinking:

nramirezuy commented 3 months ago

Ok, just figured out on my own:

 pylsp_mypy = {
    enabled = true,
    overrides = {"--python-executable", "python", true},
 }

You have to add the true at the end, but some reason this true value isn't required when set from pyproject.toml.

@Richardk2n is this expected behavior?

Richardk2n commented 1 month ago

@LaurenceWarne This seems sensible to me.

@nramirezuy The true is the placeholder for the default command line arguments, that we pass, so depending on what you insert into the overrides it is required. What exactly do you mean by set from pyprojectl.toml?

LaurenceWarne commented 1 month ago

This seems sensible to me.

:+1: I've made edits to the PR

LaurenceWarne commented 4 weeks ago

I think I've addressed everything :+1: