Closed publicimageltd closed 1 year ago
Does it work as intended if you manually set your eglot-workspace-configuration
to this?
(setq-default eglot-workspace-configuration
'(:pylsp (:plugins
(:mypy (:enabled t :overrides ["True", "--python-executable", "/home/jv/spiced/DeScribble/.venv/bin/python"])
:flake8 (:enabled t :ignore ["E501"])
:pycodestyle (:enabled :json-false)
:ruff (:enabled t :extendSelect ["D" "E" "E201"] :extendIgnore ["E741" ])))))
This helped! It did not work directly, here's the result:
(setq-default eglot-workspace-configuration
'(:pylsp (:plugins
(:pylsp_mypy (;;:enabled t
:overrides ["--python-executable"
".venv/bin/python"
t])
:flake8 (:enabled t :ignore ["E501"])
:pycodestyle (:enabled :json-false)
:ruff (:enabled t :extendSelect ["D" "E" "E201"] :extendIgnore ["E741" ])))))
So there are several changes to your suggestion:
t
instead of True
, and put it at the end (see this discussionpylsp_mypy
(which means that my setup was effectively not modifying mypy's config at all)I must admit I do not understand the last point. My source file is located in a subfolder, how does mypy know that the path refers to the venv's root? It seems like if it can recognize this, it should also know which python to use.
Maybe you could add that to your eglot customization in PET.
I just notice that in python files which do not have a venv, mypy now throws an error 'invalid file or executable'. So it would be really nice if PET could somehow handle these two cases automagically, as it does with all the other venv stuff (e.g. by using pet-executable-find
.)
This is a more precise statement of a problem which I still believe might be solvable with PET. I use pylsp with several plugins (flake8, mypy, ruff), but mypy is called with the global environment. Local checks on the shell return no errors, but opening the file in Emacs does.
I have the following configuration: pylsp, pylsp-mypy, pylsp-ruff; on Emacs eglot and PET. Eglot configuration is done on user-basis with the following setting:
The output of
eglot-show.workspace-configuration
yields:So there are some observations:
pet-lookup-eglot-server-initialization-options
. I do not know if this a problem, but at least we have an intransparent modification of a configuration variable here.In Emacs, mypy complains about missing imports which are de facto imported, and about which mypy does not complain when called from the command line.
I hope this is something PET related (maybe we could use an "environment" variable?); if not, I would be glad to profit from your expertise and get some pointers how to further investigate this issue. Configuring this lsp stuff is not a very amusing thing, it feels more like magic because of all the different layers involved.