microsoft / microsoft/vscode-black-formatter

ImportError: cannot import name 'NothingType' from 'attrs'

Open
#729 6 comments 4 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
196
Forks
49
Avg merge
1d 5h
Merged PRs (30d)
7

Description

## Diagnostic Data
- Python version (& distribution if applicable, e.g., Anaconda): Python 3.12.3
- Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): venv
- Operating system (and version): Ubuntu 24.04
- Version of tool extension you are using: 2026.4.0

## Behaviour
After updating the VS Code extension from 2025.2.0 to 2026.4.0 the Black formatter extension is no longer working. Whenever I start VS Code I get errors from the Black formatter that it couldn't start. If I check the output I see the following error messages:
```text
2026-04-30 11:11:28.488 [info] Traceback (most recent call last):
File "/home/thomas/.vscode-server/extensions/ms-python.black-formatter-2026.4.0/bundled/tool/lsp_server.py", line 74, in
from pygls.lsp.server import LanguageServer
File "/home/thomas/.vscode-server/extensions/ms-python.black-formatter-2026.4.0/bundled/libs/pygls/lsp/__init__.py", line 17, in
import cattrs
File "/home/thomas/.vscode-server/extensions/ms-python.black-formatter-2026.4.0/bundled/libs/cattrs/__init__.py", line 3, in
from .converters import BaseConverter, Converter, GenConverter, UnstructureStrategy
File "/home/thomas/.vscode-server/extensions/ms-python.black-formatter-2026.4.0/bundled/libs/cattrs/converters.py", line 18, in
from ._compat import (
File "/home/thomas/.vscode-server/extensions/ms-python.black-formatter-2026.4.0/bundled/libs/cattrs/_compat.py", line 44, in
from attrs import NOTHING, Attribute, Factory, NothingType, resolve_types
ImportError: cannot import name 'NothingType' from 'attrs' (/usr/lib/python3/dist-packages/attrs/__init__.py)

2026-04-30 11:11:28.495 [info] [Error - 11:11:28 AM] Server process exited with code 1.
2026-04-30 11:11:28.496 [info] [Error - 11:11:28 AM] Server initialization failed.
2026-04-30 11:11:28.497 [info] Message: Pending response rejected since connection got disposed
Code: -32097
2026-04-30 11:11:28.497 [info] [Info - 11:11:28 AM] Connection to server got closed. Server will restart.
2026-04-30 11:11:28.497 [info] true
2026-04-30 11:11:28.497 [info] [Error - 11:11:28 AM] Black Formatter client: couldn't create connection to server.
2026-04-30 11:11:28.497 [info] Message: Pending response rejected since connection got disposed
Code: -32097
2026-04-30 11:11:28.497 [info] [Error - 11:11:28 AM] Restarting server failed
2026-04-30 11:11:28.497 [info] Message: Pending response rejected since connection got disposed
Code: -32097
```

## Extra details
VS Code version:
```text
Version: 1.109.2 (user setup)
Commit: 591199df409fbf59b4b52d5ad4ee0470152a9b31
Date: 2026-02-10T20:18:23.520Z
Electron: 39.3.0
ElectronBuildId: 13168319
Chromium: 142.0.7444.265
Node.js: 22.21.1
V8: 14.2.231.22-electron.0
OS: Windows_NT x64 10.0.26200
```

Installed extensions:

076923.python-image-preview@0.1.2

adrianwilczynski.toggle-hidden@1.0.2

alanzhang.open-symlink-source@0.0.1

althack.ament-task-provider@0.4.1

arturodent.launch-config@0.9.0

augustocdias.tasks-shell-input@1.20.0

azurity.pcd-viewer@0.0.8

bazelbuild.vscode-bazel@0.14.0

bbenoist.doxygen@1.0.0

benjamin-simmonds.pythoncpp-debug@0.3.0

bierner.markdown-preview-github-styles@2.2.0

brobeson.vscode-cmake-lint@1.0.0

cardinal90.multi-cursor-case-preserve@1.0.5

cheshirekow.cmake-format@0.6.11

christian-kohler.path-intellisense@2.10.0

chrmarti.regex@0.6.0

colch.quick-open-prefill-selection@0.2.2

cschlosser.doxdocgen@1.4.0

dan-c-underwood.arm@1.7.4

davidanson.vscode-markdownlint@0.61.2

deitry.colcon-helper@1.3.0

docker.docker@0.18.0

donjayamanne.githistory@0.6.20

dotjoshjohnson.xml@2.5.1

drblury.protobuf-vsc@1.6.6

drcika.apc-extension@0.4.1

dunstontc.dark-plus-syntax@0.2.11

eamodio.gitlens@17.12.2

eclipse-cdt.memory-inspector@1.2.0

eclipse-cdt.serial-monitor@2.0.0

editorconfig.editorconfig@0.18.2

emeraldwalk.runonsave@1.0.3

esbenp.prettier-vscode@12.4.0

fehey.brackets-light-pro@0.4.6

foxundermoon.shell-format@7.2.8

freeidom.vscode-friendly-ui@0.0.5

george-alisson.html-preview-vscode@0.2.5

github.copilot-chat@0.37.5

github.github-vscode-theme@6.3.5

github.vscode-github-actions@0.31.5

github.vscode-pull-request-github@0.128.0

goessner.mdmath@2.7.4

gruntfuggly.activitusbar@0.0.47

gruntfuggly.auto-snippet@0.0.11

hediet.vscode-drawio@1.9.0

helly25.helly25iwyu@0.0.19

hoangkimlai.ipython@2025.8.0

hoddy3190.sync-extensions@1.0.0

iliazeus.vscode-ansi@1.1.7

intellect-ind-in.cmake-formatter@0.0.2

james-yu.latex-workshop@10.14.0

jebbs.plantuml@2.18.1

jomeinaster.bracket-peek@1.4.4

jota0222.multi-formatter@1.6.2

k--kato.intellij-idea-keybindings@1.7.7

kbysiec.vscode-search-everywhere@2.1.0

leeh.vcl-extension@1.1.9

llvm-vs-code-extensions.vscode-clangd@0.4.0

louiswt.regexp-preview@0.1.5

ludenstian.autotask@5.0.1

mads-hartmann.bash-ide-vscode@1.43.0

marus25.cortex-debug@1.12.1

mateocerquetella.xcode-12-theme@5.0.1

mcu-debug.debug-tracker-vscode@0.0.15

mcu-debug.memory-view@0.0.29

mcu-debug.peripheral-viewer@1.6.1

mcu-debug.rtos-views@0.0.15

meezilla.json@0.1.2

meisammafi.clion-plus-theme@0.0.1

mhutchie.git-graph@1.30.0

mkhl.shfmt@1.5.2

morningfrog.urdf-visualizer@5.1.0

ms-azuretools.vscode-containers@2.4.3

ms-azuretools.vscode-docker@2.0.0

ms-python.black-formatter@2026.4.0

ms-python.debugpy@2026.4.0

ms-python.flake8@2026.4.0

ms-python.isort@2026.4.0

ms-python.mypy-type-checker@2026.4.0

ms-python.python@2026.4.0

ms-python.vscode-pylance@2026.2.1

ms-python.vscode-python-envs@1.20.1

ms-toolsai.datawrangler@1.24.1

ms-toolsai.jupyter@2025.9.1

ms-toolsai.jupyter-keymap@1.1.2

ms-toolsai.jupyter-renderers@1.3.0

ms-toolsai.vscode-jupyter-cell-tags@0.1.9

ms-toolsai.vscode-jupyter-slideshow@0.1.6

ms-vscode-remote.remote-containers@0.457.0

ms-vscode-remote.remote-ssh@0.122.0

ms-vscode-remote.remote-ssh-edit@0.87.0

ms-vscode-remote.remote-wsl@0.104.3

ms-vscode-remote.vscode-remote-extensionpack@0.26.0

ms-vscode.cmake-tools@1.23.52

ms-vscode.cpp-devtools@0.4.7

ms-vscode.cpptools@1.32.2

ms-vscode.cpptools-extension-pack@1.5.1

ms-vscode.cpptools-themes@2.0.0

ms-vscode.hexeditor@1.11.1

ms-vscode.remote-explorer@0.5.0

ms-vscode.remote-server@1.5.3

ms-vscode.vscode-embedded-tools@0.8.0

ms-vscode.vscode-serial-monitor@0.13.1

mtsmfm.vscode-stl-viewer@0.3.0

njpwerner.autodocstring@0.6.1

nvidia.isaacsim-vscode-edition@0.3.0

openai.chatgpt@26.422.71525

outofsync42.select-compare-tabs@1.0.3

paragdiwan.gitpatch@0.2.1

particle.particle-vscode-theme@1.16.48

piotrpalarz.vscode-gitignore-generator@1.0.4

platformio.platformio-ide@3.3.4

pokowaka.pokowaka-iwyu@1.0.3

ranch-hand-robotics.rde-pack@1.0.0

ranch-hand-robotics.rde-ros-2@1.2.1

redhat.vscode-xml@0.29.2

redhat.vscode-yaml@1.22.0

repreng.csv@1.3.0

rioj7.command-variable@1.70.0

roehling.eclipse-color-theme@0.1.3

ryuta46.multi-command@1.6.0

sanjulaganepola.github-local-actions@1.2.5

saoudrizwan.claude-dev@3.81.0

sh4dow.theme-notepadplusplusremixed@1.0.3

shayanahmedkhan.notepadpp-color-theme@0.2.0

shd101wyy.markdown-preview-enhanced@0.8.24

shibayu36.search-in-current-file@0.0.2

sleistner.vscode-fileutils@3.10.3

stmicroelectronics.stm32-vscode-extension@3.8.0

stmicroelectronics.stm32cube-ide-build-analyzer@1.2.0

stmicroelectronics.stm32cube-ide-build-cmake@1.44.0

stmicroelectronics.stm32cube-ide-bundles-manager@1.2.0

stmicroelectronics.stm32cube-ide-clangd@1.0.4

stmicroelectronics.stm32cube-ide-core@1.2.1

stmicroelectronics.stm32cube-ide-debug-core@1.2.2

stmicroelectronics.stm32cube-ide-debug-generic-gdbserver@1.2.2

stmicroelectronics.stm32cube-ide-debug-jlink-gdbserver@1.2.2

stmicroelectronics.stm32cube-ide-debug-stlink-gdbserver@1.2.2

stmicroelectronics.stm32cube-ide-project-manager@1.2.1

stmicroelectronics.stm32cube-ide-registers@1.2.1

stmicroelectronics.stm32cube-ide-rtos@1.2.0

streetsidesoftware.code-spell-checker@4.5.6

subframe7536.custom-ui-style@0.6.9

swashata.beautiful-ui@1.7.0

takumii.markdowntable@0.13.0

tatsy.vscode-3d-preview@0.2.4

timonwong.shellcheck@0.39.3

trond-snekvik.gnu-mapfiles@1.1.0

twxs.cmake@0.0.17

uloco.theme-bluloco-light@3.7.5

usernamehw.errorlens@3.28.0

visualcodesearch.visual-code-search@0.2.0

vivaxy.vscode-conventional-commits@1.27.0

vscode-icons-team.vscode-icons@12.18.0

vscode-snippet.snippet@1.2.0

xaver.clang-format@1.9.0

yutengjing.power-edit@1.4.3

yzhang.markdown-all-in-one@3.6.3

zixuanwang.linkerscript@1.0.4

Contributor guide

Open the contributing guide

Research direction

Reproduce the startup failure using the reported Python 3.12.3 environment and inspect bundled/tool/lsp_server.py together with bundled/libs/cattrs/_compat.py. Confirm why the bundled cattrs import is incompatible with the available attrs package, then verify that the Black formatter server starts successfully and formats a file.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.