Closed moi90 closed 5 months ago
It feels like bundled set of libraries is mismatched - changes in the cattrs
introduced by this PR are not supplemented with changes in attrs
introduced here.
Is there a way to update any python libs bundled with a vscode extension?
update: further investigation shown that attrs
module is imported from my virtualenv. Maybe I can fix this by upgrading attrs in the env.
Yep, updating attrs
to >=22.2.0
worked as a workaround for me. @moi90 it might help you too.
However, the issue in general still persists - bundled version of cattrs
is using attrs
from virtualenv, and not from the bundle.
Gosh, I didn't even think before that, how this extension failure would disrupt my everyday work.
If your environment has one of these packages there make sure it is same or greater than the versions listed here: https://github.com/microsoft/vscode-black-formatter/blob/main/requirements.txt
We recommend using the bundled libs. When using black from your environment it can run into problems like this.
@karthiknadig isn't the point of bundling libs with the extension in making it independent from the environment?
There are two things here, the server itself needs to communicate with VS Code and that requires attrs
, cattrs
, pygls
etc. Then there is black and its dependencies. You can set up the extension in a way to use the bundled libs for communication but use the black from your environment for formatting. Like this:
"black-formatter.importStrategy": "useBundled",
"black-formatter.path": ["${interpreter}", "-m", "black"],
The "${interpreter}"
part there is automatically resolved to the selected interpreter.
You can even point it to black binary:
"black-formatter.importStrategy": "useBundled",
"black-formatter.path": ["black"],
ms-python.black-formatter stopped working when using black from the environment. When I do
> Format Document
, Code says "There is no formatter for 'python' files installed. However, it is installed and active.When I try to
> Black Formatter: Restart Server
, I get the following in the Black Formatter Output console:Black installed in the environment:
VS Code Version:
Extension Version: Both v2024.1.10361006 (pre-release) and v2024.0.0.
(However, it works with the bundled version of black.)