-
Notifications
You must be signed in to change notification settings - Fork 37
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
Command 'Format Document With...' resulted in an error. TypeError: 'type' object is not subscriptable #564
Comments
I am experiencing the same issue with Docker Alpine 3.20 and Python 3.8.0. The formatter is not working as expected. |
Windows 11, Pyrhon 3.8.10
|
Python 3.8 is deprecated in the latest version of black. I recommend pinning the extension to previous stable version. 2024.* |
OK, Version 2024.6.0 does work |
Diagnostic Data
Behaviour
Expected Behavior
Format documents correctly as before
Actual Behavior
I try to format this code

by

, and then

Reproduction Steps:
Do as what I have posted
Logs:
Click here for detailed logs
2025-03-06 13:30:06.780 [info] /home/x/miniconda3/envs/pp_thanos/bin/python -m black --stdin-filename /home/x/irepo/test.py - 2025-03-06 13:30:06.780 [info] CWD formatter: /home/x/irepo 2025-03-06 13:30:06.782 [info] [Error - 1:30:06 PM] Traceback (most recent call last): File "/home/x/.vscode/extensions/ms-python.black-formatter-2025.2.0/bundled/tool/lsp_server.py", line 531, in _run_tool_on_document result = utils.run_module( File "/home/x/.vscode/extensions/ms-python.black-formatter-2025.2.0/bundled/tool/lsp_utils.py", line 171, in run_module return _run_module(module, argv, use_stdin, source) File "/home/x/.vscode/extensions/ms-python.black-formatter-2025.2.0/bundled/tool/lsp_utils.py", line 156, in _run_module runpy.run_module(module, run_name="__main__") File "/home/x/miniconda3/envs/pp_thanos/lib/python3.8/runpy.py", line 203, in run_module mod_name, mod_spec, code = _get_module_details(mod_name) File "/home/x/miniconda3/envs/pp_thanos/lib/python3.8/runpy.py", line 144, in _get_module_details return _get_module_details(pkg_main_name, error) File "/home/x/miniconda3/envs/pp_thanos/lib/python3.8/runpy.py", line 111, in _get_module_details __import__(pkg_name) File "/home/x/.vscode/extensions/ms-python.black-formatter-2025.2.0/bundled/libs/black/__init__.py", line 32, in from black.cache import Cache File "/home/x/.vscode/extensions/ms-python.black-formatter-2025.2.0/bundled/libs/black/cache.py", line 16, in from black.mode import Mode File "/home/x/.vscode/extensions/ms-python.black-formatter-2025.2.0/bundled/libs/black/mode.py", line 67, in VERSION_TO_FEATURES: dict[TargetVersion, set[Feature]] = { TypeError: 'type' object is not subscriptable2025-03-06 13:30:06.782 [info] [Error - 1:30:06 PM] Request textDocument/formatting failed.
2025-03-06 13:30:06.782 [info] Message: TypeError: 'type' object is not subscriptable
Code: -32603
[object Object]
Outcome When Attempting Debugging Steps:
Did running it from the command line work?

Using a command(black test.py) to format and it works fine
Extra Details
The text was updated successfully, but these errors were encountered: