microsoft / microsoft/vscode-mypy
Monorepo: allow a way to configure `cwd` based on `pyproject.toml` or `ini` file location
- Dominant language
- Python
- Stars
- 150
- Forks
- 39
- Avg merge
- 21h 45m
- Merged PRs (30d)
- 8
Description
The instructions added in https://github.com/microsoft/vscode-mypy/commit/aee38320a767a728b2ff9dd7383cd100c0516e3e don't work in the presence of additional directories. Consider:
```
- libA
- pyproject.toml
- subDirA
- myfile.py
- libB
- pyproject.toml
```
when running on `myfile.py` I want the `cwd` to be `libA`, not `subDirA`. I think the correct value should be `${fileWorkspaceFolder}` but this produces a crash before and after this patch.
It would also be good to log something better when this crash happens. Right now you just get
```
2024-01-24 10:04:59.330 [info] Server: Start requested.
2024-01-24 10:04:59.330 [info] [Error - 10:04:59 AM] Mypy Type Checker client: couldn't create connection to server.
2024-01-24 10:04:59.331 [info] Launching server using command python_monorepo/common/.venv/bin/python failed. Error: spawn python_monorepo/common/.venv/bin/python ENOENT
2024-01-24 10:04:59.331 [error] Server: Start failed: Launching server using command python_monorepo/common/.venv/bin/python failed. Error: spawn python_monorepo/common/.venv/bin/python ENOENT
```
This is a common thing when using multiple virtual environments as suggested in https://github.com/microsoft/vscode-python/wiki/Mono-Repo-Set%E2%80%90up-Guide#scenario-2-separate-virtual-environments. I think what we want is `${fileWorkspaceFolder}` or `${workspaceFolder}` -- I'm not sure because the docs are confusing. But we want the workspace folder to which the currently open file belongs.
https://code.visualstudio.com/docs/editor/variables-reference
Contributor guide
Research direction
Reproduce the reported monorepo layout with separate pyproject.toml files and a file in a nested directory, then compare the available ${fileWorkspaceFolder} and ${workspaceFolder} behavior against the linked VS Code variables reference. Trace the cwd resolution and server-launch error path; done means the correct project directory is selected and an invalid interpreter produces a useful log message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100