Closed petergaultney closed 1 month ago
Is there any reason, why this is a separate file executed using subprocess.run and not just a normal part of the code?
yes, the idea is that it allows users to write any kind of logic they want for determining the python environment based on the path of the file being checked.
For poetry and pipenv, something like my code could easily be standard, but this approach lets users essentially write arbitrary config for their own setups.
The general idea here is that Python programmers can probably think of a hundred different ways to dynamically configure which install of mypy gets used and how it gets run. I'm doing this by having
pylsp-mypy
look for a script calledget-venv.py
(which probably needs a different, more general/descriptive name, and/or could potentially have a configurable name/path via standardpython-language-server
config), and if it exists, it calls it with a JSON payload of the document path and workspace path, and processing the output as a simple JSON payload to modify howmypy
is called.An example
get-venv.py
script is shown below (a simplified version of my own). In my case, I always havemypy
installed within the venvs themselves, so the simplest option for me is to use my venv manager to run mypy.Other people might have different ways of setting up their config dynamically - in most cases I think they would be able to just add more items to the returned list, though in some cases they might end up wishing to modify the full invocation, which currently is not possible because I haven't provided it to the
get-venv.py
script. That would be easy enough to change.