Search code examples
pythonvisual-studiogithub-copilot

Visual Studio Community Edition 2022 : Black doesn't support Format selection command


The same issue has been resolved in VS Code, but the problem remains in Visual Studio Community 2022. The hints given in the VS Code post don't help me solve the problem, the same error message occurs when I use Github Copilot with the TAB key. VS Code Post : Black does not support "Format Selection" command

Python version : 3.8.0 Visual Studio Details : VS Community Edition Error message : Black error I would appreciate any hint and help to solve this problem.

I tried any hint from the VS Code post : Black does not support "Format Selection" command I searched the web for help without any appropriate result.


Solution

  • The error is from the python formatter Black which does not support the Format Selection command.

    You can switch to the PEP8 or yapf formatter which will not give you the error. In Visual Studio go to Tools -> Options -> Text Editor -> Python -> Formatting. Select autopep8 or yapf and when you use it the first time accept the installer.