OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

WSL2 vscode black extension isn't formatting on save

  • Thread starter Thread starter Kathryn Cogert
  • Start date Start date
K

Kathryn Cogert

Guest
I'm having some trouble getting the vscode black extension to work in vscode. I'm using python 3.10.12, ubuntu 22.04.3, vscode 1.90.1

Here's my settings json:

Code:
{
    "workbench.colorTheme": "Nu Disco Dark",
    "codeium.enableConfig": {
        "*": true,
        "markdown": true
    },
  "remote.autoForwardPortsSource": "hybrid",

  "editor.defaultFormatter": "ms-python.black-formatter",
  "editor.formatOnSave": true,
  "notebook.defaultFormatter": "ms-python.black-formatter",
  "notebook.formatOnSave.enabled": true,

  "python.languageServer": "Pylance",
  "python.analysis.typeCheckingMode": "basic",
  "python.analysis.inlayHints.variableTypes": true,
  "python.analysis.autoImportCompletions": true,
  "python.analysis.inlayHints.pytestParameters": true,
  "python.analysis.inlayHints.functionReturnTypes": true
}

I'm expecting this test.py file located in my ~/src directory to format itself on save, but nothing seems to happen:

Code:
'this should be double quotes'

# this should get spaces between characters
x=1+1

I tried to restart the black server, but got this error [IMG alt="Command 'Black Formatter: Restart Server' resulted in an
error Cannot read properties of undefined (reading 'getDebuggerPackagePath')"]https://i.sstatic.net/TPdkxOJj.png[/IMG]


Edit 6/19/24:

I'm running my vscode window insider a virtual environment and I have black==24.4.2 installed both inside and outside the venv. My black-formatter: import strategy is useBundled.
<p>I'm having some trouble getting the vscode black extension to work in vscode. I'm using python 3.10.12, ubuntu 22.04.3, vscode 1.90.1</p>
<p>Here's my settings json:</p>
<pre><code>{
"workbench.colorTheme": "Nu Disco Dark",
"codeium.enableConfig": {
"*": true,
"markdown": true
},
"remote.autoForwardPortsSource": "hybrid",

"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"notebook.defaultFormatter": "ms-python.black-formatter",
"notebook.formatOnSave.enabled": true,

"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "basic",
"python.analysis.inlayHints.variableTypes": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.inlayHints.pytestParameters": true,
"python.analysis.inlayHints.functionReturnTypes": true
}
</code></pre>
<p>I'm expecting this <code>test.py</code> file located in my <code>~/src</code> directory to format itself on save, but nothing seems to happen:</p>
<pre><code>'this should be double quotes'

# this should get spaces between characters
x=1+1
</code></pre>
<p>I tried to restart the black server, but got this error
<a href="https://i.sstatic.net/TPdkxOJj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TPdkxOJj.png" alt="Command 'Black Formatter: Restart Server' resulted in an
error Cannot read properties of undefined (reading 'getDebuggerPackagePath')" /></a></p>
<p> Edit 6/19/24: <br></p>
<p>I'm running my vscode window insider a virtual environment and I have black==24.4.2 installed both inside and outside the venv. My <code>black-formatter: import strategy</code> is useBundled.</p>
 
Top