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.