-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow defining black-formatter.interpreter per .vscode folder in multi-root workspace #219
Comments
@karthiknadig are you sure that is the right link? It is the same you've sent me for the other PR :-) Anyway, I've verified this issue is not fixed by this build. |
Sorry, this is the build that allow interpreter setting at resource level: |
That one doesn't work as well, although the config is not greyed out in that version. |
@lukaspiatkowski Can you share the logs, the settings passed in should have the pythons selected for each root? We start only one server even in multi root case. But for each root we launch a sub-server if it uses different python. Are you using python extension to select the python for the various roots? |
Sure, here is the log: https://gist.github.com/lukaspiatkowski/f6a009aabf7c8f29c80402034d51aed4 |
@lukaspiatkowski I am not sure why it had to be that complicated, here is all that you really need:
These are the settings passed:
Here you can see correct environment being picked up:
You should be able to do this with the relese version, and you don't need separate Formatter extension will automatically use the right one for each repo:
Nothing set for the interpreter in the code-workspace file:
|
Well, obviously that is not the repository I am working on daily, it is just a minimal example to reproduce the problem. If you want a more complex one then I've pushed a new commit to that test repository. Here are full logs: https://gist.github.com/lukaspiatkowski/d4d531d71370d63abbdb5f1a35c1ee5e What I would expect from settings:
Instead, what I get is:
|
There was a bug in the fall back mechanism, but if you have black install in all three envs it should work. I am going to make a fix for the fallback mechanism, with the fix you should see this:
|
We don't have black installed in all of our projects. In fact we have >10 projects defined on few deepnesses of folders and they all use black from the root venv (that is very convenient to make black consistent in the repository and have only the root venv up-to-date for commit hooks to work) except for one project that uses a newer version of Python and newer version of black. That is why I've opened this issue, I am not sure which fallback mechanism you are referring to when you say it is broken as the are few things that work inconsistently here. Having all settings behave exactly like |
There are two fallback mechanisms. One for single python scenario, and another for multi-python scenario. In multi-python scenario. Each root in the multi-root case gets its own server. All of these are co-ordinated my the main server. The sub-server runner sets up the |
Ok, understood. But that fix doesn't really close this issue. Or is it that, based on what you said, you won't implement this feature request? |
This issue actually had two separate things,
|
Thanks for being so very responsive! I am really impressed by how speedy you were addressing those issues. For what it is worth, I've downloaded and tried out the vsix from #229 and it works very well. On the repo mentioned above, the logs are here: https://gist.github.com/lukaspiatkowski/9ad051073e889fbb7191c7323bfad513 What I would expect from settings:
Instead, what I get is:
But to be honest, that last case was purely academical, as we don't need |
Oh, BTW, should I open similar issues for other ms-python extensions (I am thinking here about isort and mypy) or have you commited those changes to a common repository and solved it for all of those extensions? |
I will be propagating these fixes across to all extensions. No need to open issues on all the repos. |
Currently, the
black-formatter.interpreter
setting is defined as "window" scope here:vscode-black-formatter/package.json
Line 119 in e0f7830
Because of this in a multi-root workspace setting it is impossible to define interpreters independently per each project. Consider this project layout:
And this
my-workspace.code-workspace
setting:Now one might want to use
In
root
-> black-formatter.interpreter == root/venv/bin/pythonin
proj1
-> black-formatter.interpreter == root/venv/bin/python (Note that the default python interpreter still has to beproj1/venv/bin/python
for pylance to work)in
proj2
-> black-formatter.interpreter == root/proj2/venv/bin/pythonRight now because
black-formatter.interpreter
can only be set in.code-workspace
there is no way to express this configuration.A workaround: use
black-formatter.path
which is declared with scope "resource"vscode-black-formatter/package.json
Line 86 in e0f7830
root/.vscode/settings.json
:proj1/.vscode/settings.json
:proj2/.vscode/settings.json
:But this doesn't make use of the speedups this extension is supposed to give with not using black binary directly.
The text was updated successfully, but these errors were encountered: