matangover/mypy-vscode

Ability to run multiple daemons for single workspace (e.g. for monorepos)

luisacabs-out opened this issue ยท 5 comments

Hi there.

I have a multi-root project and usually I work in the root of my project and select the venv for the service I'm working on. But without updating the target everytime mypy will run for the entire project, which I don't want.

Is there an option to set the target settings dynamically? In theory I could retrieve the target from the python interpreter I'm using, however I don't think I can add that to the settings as it is.

Is there a chance this could be implemented?

First of all, interesting use case, second of all, how did you get 5 upvotes so fast ๐Ÿ˜…

Why does it matter to you that mypy runs for the entire workspace? There is one mypy daemon for each workspace folder. Mypy will only recheck changed files and their dependencies

First of all, I am sorry for the very late reply.

Regarding the use case:

I have a project with multiple packages and services in the same repo. Every service has dependencies to these packages, but at the moment we are using local dependencies instead of releasing the package.
Because of this, when I open the service in vscode (not at the root of the repo, but the root of the service), I lose intellisense regarding those packages. Therefore I usually work at the root of my repo in every service/package.

With this setup, I lose the mypy configuration I have for each service/package. I'm using other linters like flake8 for which I use the same configuration for all services, but for mypy I have different configurations for each service.
So ideally I would like to be able to define a configuration file in vscode settings, that's based on the python interpreter I am using atm ๐Ÿ˜„

Thanks for explaining. Alright, I understand your use case. I think the core missing feature for you here is to run multiple mypy daemons for a single workspace (or workspace folder).

You would specify the new setting mypy.rootPaths: ["src/service1", "src/service2"] etc.
Then my extension would run a separate mypy dameon for each root path. Each daemon would have its own configuration file and targets. This could be useful for people that are working with monorepos.

Please advise if this would solve your use case

Yes, that would solve it ๐Ÿ™